jdk/test/sun/security/provider/SecureRandom/DRBGAlg.java
changeset 37896 cd841af7dcd0
parent 37796 256c45c4af5d
equal deleted inserted replaced
37895:f59fdd7fb4fb 37896:cd841af7dcd0
    45 
    45 
    46     public static void main(String[] args) throws Exception {
    46     public static void main(String[] args) throws Exception {
    47 
    47 
    48         check(null, "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    48         check(null, "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    49         check("", "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    49         check("", "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    50         check("sha-1", "Hash_DRBG", "SHA-1", "reseed_only", ",128");
       
    51         check("sha-256", "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    50         check("sha-256", "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    52         check("SHA-3");
    51         check("SHA-3");
    53         check("hash_drbg", "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    52         check("hash_drbg", "Hash_DRBG", "SHA-256", "reseed_only", ",128");
    54         check("hmac_drbg", "HMAC_DRBG", "SHA-256", "reseed_only", ",128");
    53         check("hmac_drbg", "HMAC_DRBG", "SHA-256", "reseed_only", ",128");
    55         check("ctr_drbg", "CTR_DRBG", "AES-", "reseed_only", ",128", "use_df");
    54         check("ctr_drbg", "CTR_DRBG", "AES-", "reseed_only", ",128", "use_df");
    59                 Collections.emptyList(),
    58                 Collections.emptyList(),
    60                 Arrays.asList("hash_drbg","sha-512","Pr_and_Reseed","192"),
    59                 Arrays.asList("hash_drbg","sha-512","Pr_and_Reseed","192"),
    61                 "Hash_DRBG", "SHA-512", "pr_and_reseed", ",192");
    60                 "Hash_DRBG", "SHA-512", "pr_and_reseed", ",192");
    62 
    61 
    63         check("Hash_DRBG,Hmac_DRBG");
    62         check("Hash_DRBG,Hmac_DRBG");
    64         check("SHA-1,SHA-256");
    63         check("SHA-224,SHA-256");
    65         check("128,256");
    64         check("128,256");
    66         check("none,reseed_only");
    65         check("none,reseed_only");
    67         check("use_df,no_df");
    66         check("use_df,no_df");
    68         check("Hash_DRBG,,SHA-1");
    67         check("Hash_DRBG,,SHA-256");
    69 
    68 
    70         check(null, DrbgParameters.instantiation(112, PR_AND_RESEED, null),
    69         check(null, DrbgParameters.instantiation(112, PR_AND_RESEED, null),
    71                 "Hash_DRBG", "SHA-256", "pr_and_reseed", ",112");
    70                 "Hash_DRBG", "SHA-256", "pr_and_reseed", ",112");
    72         check(null, DrbgParameters.instantiation(256, PR_AND_RESEED, null),
    71         check(null, DrbgParameters.instantiation(256, PR_AND_RESEED, null),
    73                 "Hash_DRBG", "SHA-256", "pr_and_reseed", ",256");
    72                 "Hash_DRBG", "SHA-256", "pr_and_reseed", ",256");
    74         check(null, DrbgParameters.instantiation(384, PR_AND_RESEED, null));
    73         check(null, DrbgParameters.instantiation(384, PR_AND_RESEED, null));
    75         check("sha-1", DrbgParameters.instantiation(112, PR_AND_RESEED, null),
    74         check("sha-224", DrbgParameters.instantiation(112, PR_AND_RESEED, null),
    76                 "Hash_DRBG", "SHA-1", "pr_and_reseed", ",112");
    75                 "Hash_DRBG", "SHA-224", "pr_and_reseed", ",112");
    77         check("sha-1", DrbgParameters.instantiation(192, PR_AND_RESEED, null));
    76         check("sha-224", DrbgParameters.instantiation(256, PR_AND_RESEED, null));
    78         check("hash_drbg,sha-512,Pr_and_Reseed,192",
    77         check("hash_drbg,sha-512,Pr_and_Reseed,192",
    79                 DrbgParameters.instantiation(112, NONE, null),
    78                 DrbgParameters.instantiation(112, NONE, null),
    80                 "Hash_DRBG", "SHA-512", "reseed_only", ",112");
    79                 "Hash_DRBG", "SHA-512", "reseed_only", ",112");
    81         check("hash_drbg,sha-512,Pr_and_Reseed,192",
    80         check("hash_drbg,sha-512,Pr_and_Reseed,192",
    82                 DrbgParameters.instantiation(-1, NONE, null),
    81                 DrbgParameters.instantiation(-1, NONE, null),
    84         // getInstance params can be stronger than definition
    83         // getInstance params can be stronger than definition
    85         check("hash_drbg,sha-256,None,112",
    84         check("hash_drbg,sha-256,None,112",
    86                 DrbgParameters.instantiation(192, PR_AND_RESEED, null),
    85                 DrbgParameters.instantiation(192, PR_AND_RESEED, null),
    87                 "Hash_DRBG", "SHA-256", "pr_and_reseed", ",192");
    86                 "Hash_DRBG", "SHA-256", "pr_and_reseed", ",192");
    88 
    87 
    89         check("hash_drbg,sha-1", new MoreDrbgParameters(
    88         check("hash_drbg,sha-224", new MoreDrbgParameters(
    90                     null, null, "sha-512", null, false,
    89                     null, null, "sha-512", null, false,
    91                     DrbgParameters.instantiation(-1, NONE, null)),
    90                     DrbgParameters.instantiation(-1, NONE, null)),
    92                 "Hash_DRBG", "SHA-512");
    91                 "Hash_DRBG", "SHA-512");
    93         check("hash_drbg,sha-1", new MoreDrbgParameters(
    92         check("hash_drbg,sha-224", new MoreDrbgParameters(
    94                     null, null, null, null, false,
    93                     null, null, null, null, false,
    95                     DrbgParameters.instantiation(-1, NONE, null)),
    94                     DrbgParameters.instantiation(-1, NONE, null)),
    96                 "Hash_DRBG", "SHA-1");
    95                 "Hash_DRBG", "SHA-224");
    97         check("hash_drbg", new MoreDrbgParameters(
    96         check("hash_drbg", new MoreDrbgParameters(
    98                     null, "hmac_drbg", null, null, false,
    97                     null, "hmac_drbg", null, null, false,
    99                     DrbgParameters.instantiation(-1, NONE, null)),
    98                     DrbgParameters.instantiation(-1, NONE, null)),
   100                 "HMAC_DRBG", "SHA-256");
    99                 "HMAC_DRBG", "SHA-256");
   101 
   100 
   102         check("hash_drbg,sha-1", new MoreDrbgParameters(
   101         check("hash_drbg,sha-224", new MoreDrbgParameters(
   103                     null, null, "sha-3", null, false,
   102                     null, null, "sha-3", null, false,
   104                     DrbgParameters.instantiation(-1, NONE, null)));
   103                     DrbgParameters.instantiation(-1, NONE, null)));
   105         check("hash_drbg,sha-1", new MoreDrbgParameters(
   104         check("hash_drbg,sha-224", new MoreDrbgParameters(
   106                     null, "Unknown_DRBG", null, null, false,
   105                     null, "Unknown_DRBG", null, null, false,
   107                     DrbgParameters.instantiation(-1, NONE, null)));
   106                     DrbgParameters.instantiation(-1, NONE, null)));
   108     }
   107     }
   109 
   108 
   110     /**
   109     /**