/** * Get the key identifier, which is composed of the 160-bit SHA-1 hash of the value of the BIT STRING * {@code subjectPublicKey} (excluding the tag, length, and number of unused bits), as per * <a href="https://tools.ietf.org/html/rfc3280">RFC 3280</a>. * * @param publicKey the public key * @return the key identifier */ public static byte[] getKeyIdentifier(final PublicKey publicKey) { DERDecoder decoder = new DERDecoder(publicKey.getEncoded()); decoder.startSequence(); decoder.skipElement(); // skip the algorithm byte[] subjectPublicKey = decoder.decodeBitString(); decoder.endSequence(); final MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("SHA-1"); messageDigest.update(subjectPublicKey); return messageDigest.digest(); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } } }
private static PrivateKey parsePemPrivateKey(String type, ByteIterator byteIterator) throws IllegalArgumentException { if (! type.equals(PRIVATE_KEY_FORMAT)) { throw log.invalidPemType(PRIVATE_KEY_FORMAT, type); } try { byte[] der = byteIterator.drain(); DERDecoder derDecoder = new DERDecoder(der); derDecoder.startSequence(); // Version if (derDecoder.peekType() != ASN1.INTEGER_TYPE) throw log.asnUnexpectedTag(); derDecoder.skipElement(); // AlgorithmIdentifier derDecoder.startSequence(); String algorithm = derDecoder.decodeObjectIdentifierAsKeyAlgorithm(); if (algorithm != null) { return KeyFactory.getInstance(algorithm).generatePrivate(new PKCS8EncodedKeySpec(der)); } throw log.asnUnrecognisedAlgorithm(algorithm); } catch (Exception cause) { throw log.privateKeyParseError(cause); } }
decoder.skipElement(); byte[] serverSignature = decoder.decodeBitString(); decoder.endSequence();
decoder.skipElement(); byte[] clientSignature = decoder.decodeBitString(); decoder.endSequence();
/** * Get the key identifier, which is composed of the 160-bit SHA-1 hash of the value of the BIT STRING * {@code subjectPublicKey} (excluding the tag, length, and number of unused bits), as per * <a href="https://tools.ietf.org/html/rfc3280">RFC 3280</a>. * * @param publicKey the public key * @return the key identifier */ public static byte[] getKeyIdentifier(final PublicKey publicKey) { DERDecoder decoder = new DERDecoder(publicKey.getEncoded()); decoder.startSequence(); decoder.skipElement(); // skip the algorithm byte[] subjectPublicKey = decoder.decodeBitString(); decoder.endSequence(); final MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("SHA-1"); messageDigest.update(subjectPublicKey); return messageDigest.digest(); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } } }
/** * Get the key identifier, which is composed of the 160-bit SHA-1 hash of the value of the BIT STRING * {@code subjectPublicKey} (excluding the tag, length, and number of unused bits), as per * <a href="https://tools.ietf.org/html/rfc3280">RFC 3280</a>. * * @param publicKey the public key * @return the key identifier */ public static byte[] getKeyIdentifier(final PublicKey publicKey) { DERDecoder decoder = new DERDecoder(publicKey.getEncoded()); decoder.startSequence(); decoder.skipElement(); // skip the algorithm byte[] subjectPublicKey = decoder.decodeBitString(); decoder.endSequence(); final MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("SHA-1"); messageDigest.update(subjectPublicKey); return messageDigest.digest(); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } } }
/** * Get the key identifier, which is composed of the 160-bit SHA-1 hash of the value of the BIT STRING * {@code subjectPublicKey} (excluding the tag, length, and number of unused bits), as per * <a href="https://tools.ietf.org/html/rfc3280">RFC 3280</a>. * * @param publicKey the public key * @return the key identifier */ public static byte[] getKeyIdentifier(final PublicKey publicKey) { DERDecoder decoder = new DERDecoder(publicKey.getEncoded()); decoder.startSequence(); decoder.skipElement(); // skip the algorithm byte[] subjectPublicKey = decoder.decodeBitString(); decoder.endSequence(); final MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("SHA-1"); messageDigest.update(subjectPublicKey); return messageDigest.digest(); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } } }
private static PrivateKey parsePemPrivateKey(String type, ByteIterator byteIterator) throws IllegalArgumentException { if (! type.equals(PRIVATE_KEY_FORMAT)) { throw log.invalidPemType(PRIVATE_KEY_FORMAT, type); } try { byte[] der = byteIterator.drain(); DERDecoder derDecoder = new DERDecoder(der); derDecoder.startSequence(); // Version if (derDecoder.peekType() != ASN1.INTEGER_TYPE) throw log.asnUnexpectedTag(); derDecoder.skipElement(); // AlgorithmIdentifier derDecoder.startSequence(); String algorithm = derDecoder.decodeObjectIdentifierAsKeyAlgorithm(); if (algorithm != null) { return KeyFactory.getInstance(algorithm).generatePrivate(new PKCS8EncodedKeySpec(der)); } throw log.asnUnrecognisedAlgorithm(algorithm); } catch (Exception cause) { throw log.privateKeyParseError(cause); } }
private static PrivateKey parsePemPrivateKey(String type, ByteIterator byteIterator) throws IllegalArgumentException { if (! type.equals(PRIVATE_KEY_FORMAT)) { throw log.invalidPemType(PRIVATE_KEY_FORMAT, type); } try { byte[] der = byteIterator.drain(); DERDecoder derDecoder = new DERDecoder(der); derDecoder.startSequence(); // Version if (derDecoder.peekType() != ASN1.INTEGER_TYPE) throw log.asnUnexpectedTag(); derDecoder.skipElement(); // AlgorithmIdentifier derDecoder.startSequence(); String algorithm = derDecoder.decodeObjectIdentifierAsKeyAlgorithm(); if (algorithm != null) { return KeyFactory.getInstance(algorithm).generatePrivate(new PKCS8EncodedKeySpec(der)); } throw log.asnUnrecognisedAlgorithm(algorithm); } catch (Exception cause) { throw log.privateKeyParseError(cause); } }
private static PrivateKey parsePemPrivateKey(String type, ByteIterator byteIterator) throws IllegalArgumentException { if (! type.equals(PRIVATE_KEY_FORMAT)) { throw log.invalidPemType(PRIVATE_KEY_FORMAT, type); } try { byte[] der = byteIterator.drain(); DERDecoder derDecoder = new DERDecoder(der); derDecoder.startSequence(); // Version if (derDecoder.peekType() != ASN1.INTEGER_TYPE) throw log.asnUnexpectedTag(); derDecoder.skipElement(); // AlgorithmIdentifier derDecoder.startSequence(); String algorithm = derDecoder.decodeObjectIdentifierAsKeyAlgorithm(); if (algorithm != null) { return KeyFactory.getInstance(algorithm).generatePrivate(new PKCS8EncodedKeySpec(der)); } throw log.asnUnrecognisedAlgorithm(algorithm); } catch (Exception cause) { throw log.privateKeyParseError(cause); } }
decoder.skipElement(); byte[] serverSignature = decoder.decodeBitString(); decoder.endSequence();
decoder.skipElement(); byte[] serverSignature = decoder.decodeBitString(); decoder.endSequence();
decoder.skipElement(); byte[] serverSignature = decoder.decodeBitString(); decoder.endSequence();
decoder.skipElement(); byte[] clientSignature = decoder.decodeBitString(); decoder.endSequence();
decoder.skipElement(); byte[] clientSignature = decoder.decodeBitString(); decoder.endSequence();
decoder.skipElement(); byte[] clientSignature = decoder.decodeBitString(); decoder.endSequence();