Lines Matching defs:key

44  * A utility class to get key length, valiate keys, etc.
49 * Returns the key size of the given key object in bits.
51 * @param key the key object, cannot be null
52 * @return the key size of the given key object in bits, or -1 if the
53 * key size is not accessible
55 public static final int getKeySize(Key key) {
58 if (key instanceof Length) {
60 Length ruler = (Length)key;
71 // try to parse the length from key specification
72 if (key instanceof SecretKey) {
73 SecretKey sk = (SecretKey)key;
77 } // Otherwise, it may be a unextractable key of PKCS#11, or
78 // a key we are not able to handle.
79 } else if (key instanceof RSAKey) {
80 RSAKey pubk = (RSAKey)key;
82 } else if (key instanceof ECKey) {
83 ECKey pubk = (ECKey)key;
85 } else if (key instanceof DSAKey) {
86 DSAKey pubk = (DSAKey)key;
88 } else if (key instanceof DHKey) {
89 DHKey pubk = (DHKey)key;
91 } // Otherwise, it may be a unextractable key of PKCS#11, or
92 // a key we are not able to handle.
98 * Returns whether the key is valid or not.
103 * the key object, cannot be null
108 public static final void validate(Key key)
110 if (key == null) {
112 "The key to be validated cannot be null");
115 if (key instanceof DHPublicKey) {
116 validateDHPublicKey((DHPublicKey)key);
122 * Returns whether the key spec is valid or not.
127 * the key spec object, cannot be null
136 "The key spec to be validated cannot be null");
160 * Returns whether the Diffie-Hellman public key is valid or not.
165 * the key is invalid.
166 * 2. Compute y^q mod p. If the result == 1, the key is valid.
167 * Otherwise the key is invalid.
194 "Diffie-Hellman public key is too small");
198 "Diffie-Hellman public key is too large");