< prev index next >

test/jdk/sun/security/ec/ed/EdDSAParamSpec.java

Print this page
*** 26,11 ***
  import java.security.PublicKey;
  import java.security.SecureRandom;
  import java.security.Signature;
  import java.security.spec.EdDSAParameterSpec;
  import java.util.Arrays;
! import jdk.test.lib.Convert;
  
  /*
   * @test
   * @bug 8209632
   * @summary Test EdDSAParameterSpec.
--- 26,11 ---
  import java.security.PublicKey;
  import java.security.SecureRandom;
  import java.security.Signature;
  import java.security.spec.EdDSAParameterSpec;
  import java.util.Arrays;
! import java.util.Hex;
  
  /*
   * @test
   * @bug 8209632
   * @summary Test EdDSAParameterSpec.

*** 76,11 ***
              byte[] maxCtx = new byte[255];
              RND.nextBytes(maxCtx);
              for (byte[] context : new byte[][]{"others".getBytes(), maxCtx}) {
                  System.out.printf("Testing signature for name: %s,"
                          + " algorithm spec: (prehash:%s, context:%s)%n",
!                         name, preHash, Convert.byteArrayToHexString(context));
                  EdDSAParameterSpec params
                          = new EdDSAParameterSpec(preHash, context);
                  verifyPublic(sig, kp.getPublic(), MSG, params, initParam,
                          origSign);
              }
--- 76,11 ---
              byte[] maxCtx = new byte[255];
              RND.nextBytes(maxCtx);
              for (byte[] context : new byte[][]{"others".getBytes(), maxCtx}) {
                  System.out.printf("Testing signature for name: %s,"
                          + " algorithm spec: (prehash:%s, context:%s)%n",
!                         name, preHash, Hex.encoder().encode(context));
                  EdDSAParameterSpec params
                          = new EdDSAParameterSpec(preHash, context);
                  verifyPublic(sig, kp.getPublic(), MSG, params, initParam,
                          origSign);
              }

*** 127,12 ***
              // which is set through the signature instance.
              if (!(equals(context, initContext) && equals(preHash, initPreHash))) {
                  throw new RuntimeException(String.format("Signature verification"
                          + " success with different param context(actual:%s, "
                          + "expected:%s), Prehash(actual:%s, expected:%s)",
!                         Convert.byteArrayToHexString(context),
!                         Convert.byteArrayToHexString(initContext),
                          preHash, initPreHash));
              } else {
                  System.out.println("Atleast a case matched");
              }
          }
--- 127,12 ---
              // which is set through the signature instance.
              if (!(equals(context, initContext) && equals(preHash, initPreHash))) {
                  throw new RuntimeException(String.format("Signature verification"
                          + " success with different param context(actual:%s, "
                          + "expected:%s), Prehash(actual:%s, expected:%s)",
!                         Hex.encoder().encode(context),
!                         Hex.encoder().encode(initContext),
                          preHash, initPreHash));
              } else {
                  System.out.println("Atleast a case matched");
              }
          }

*** 163,12 ***
              return false;
          }
          boolean equals = Arrays.equals(actual, expected);
          if (!equals) {
              throw new RuntimeException(String.format("Actual array: %s, "
!                     + "Expected array:%s", Convert.byteArrayToHexString(actual),
!                     Convert.byteArrayToHexString(expected)));
          }
          return equals;
      }
  
  }
--- 163,12 ---
              return false;
          }
          boolean equals = Arrays.equals(actual, expected);
          if (!equals) {
              throw new RuntimeException(String.format("Actual array: %s, "
!                     + "Expected array:%s", Hex.encoder().encode(actual),
!                     Hex.encoder().encode(expected)));
          }
          return equals;
      }
  
  }
< prev index next >