Lines Matching defs:key

79     protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec)
81 if (key == null) {
82 throw new InvalidKeySpecException("key == null");
89 if (!"RSA".equals(key.getAlgorithm())) {
90 throw new InvalidKeySpecException("Key must be a RSA key");
93 if (key instanceof RSAPublicKey && RSAPublicKeySpec.class.isAssignableFrom(keySpec)) {
94 RSAPublicKey rsaKey = (RSAPublicKey) key;
98 } else if (key instanceof PublicKey && RSAPublicKeySpec.class.isAssignableFrom(keySpec)) {
99 final byte[] encoded = key.getEncoded();
100 if (!"X.509".equals(key.getFormat()) || encoded == null) {
108 } else if (key instanceof RSAPrivateCrtKey
110 RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
117 } else if (key instanceof RSAPrivateCrtKey
119 RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
123 } else if (key instanceof RSAPrivateKey
125 RSAPrivateKey rsaKey = (RSAPrivateKey) key;
129 } else if (key instanceof PrivateKey
131 final byte[] encoded = key.getEncoded();
132 if (!"PKCS#8".equals(key.getFormat()) || encoded == null) {
146 throw new InvalidKeySpecException("Encoded key is not an RSAPrivateCrtKey");
148 } else if (key instanceof PrivateKey && RSAPrivateKeySpec.class.isAssignableFrom(keySpec)) {
149 final byte[] encoded = key.getEncoded();
150 if (!"PKCS#8".equals(key.getFormat()) || encoded == null) {
158 } else if (key instanceof PrivateKey
160 final byte[] encoded = key.getEncoded();
161 if (!"PKCS#8".equals(key.getFormat())) {
163 + key.getFormat());
169 } else if (key instanceof PublicKey && X509EncodedKeySpec.class.isAssignableFrom(keySpec)) {
170 final byte[] encoded = key.getEncoded();
171 if (!"X.509".equals(key.getFormat())) {
173 + key.getFormat());
180 throw new InvalidKeySpecException("Unsupported key type and key spec combination; key="
181 + key.getClass().getName() + ", keySpec=" + keySpec.getName());
186 protected Key engineTranslateKey(Key key) throws InvalidKeyException {
187 if (key == null) {
188 throw new InvalidKeyException("key == null");
191 if ((key instanceof OpenSSLRSAPublicKey) || (key instanceof OpenSSLRSAPrivateKey)) {
192 return key;
193 } else if (key instanceof RSAPublicKey) {
194 RSAPublicKey rsaKey = (RSAPublicKey) key;
202 } else if (key instanceof RSAPrivateCrtKey) {
203 RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
220 } else if (key instanceof RSAPrivateKey) {
221 RSAPrivateKey rsaKey = (RSAPrivateKey) key;
230 } else if ((key instanceof PrivateKey) && ("PKCS#8".equals(key.getFormat()))) {
231 byte[] encoded = key.getEncoded();
240 } else if ((key instanceof PublicKey) && ("X.509".equals(key.getFormat()))) {
241 byte[] encoded = key.getEncoded();
251 throw new InvalidKeyException("Key must be an RSA public or private key; was "
252 + key.getClass().getName());