/** * 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); } } }
byte[] r = derDecoder.drainElementValue(); byte[] s = derDecoder.drainElementValue(); derDecoder.endSequence(); int rLength = r.length; int sLength = s.length;
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
decoder.endSequence(); return trustedAuthorities;
final byte[] publicBytes = decoder.drainElement(); final byte[] privateBytes = decoder.drainElement(); decoder.endSequence(); final KeyFactory keyFactory = KeyFactory.getInstance(matchedAlgorithm); final PublicKey publicKey = keyFactory.generatePublic(new X509EncodedKeySpec(publicBytes)); decoder.endSequence(); return credentialType.cast(new X509CertificateChainPublicCredential(array)); } catch (ASN1Exception | CertificateException | ArrayIndexOutOfBoundsException e) { final byte[] salt = decoder.decodeOctetString(); final int iterationCount = decoder.decodeInteger().intValue(); decoder.endSequence(); passwordSpec = new IteratedSaltedHashPasswordSpec(hash, salt, iterationCount); break; final String realm = decoder.decodeOctetStringAsString(); final byte[] digest = decoder.decodeOctetString(); decoder.endSequence(); passwordSpec = new DigestPasswordSpec(username, realm, digest); break; final String seed = decoder.decodeIA5String(); final int sequenceNumber = decoder.decodeInteger().intValue(); decoder.endSequence(); passwordSpec = new OneTimePasswordSpec(hash, seed, sequenceNumber); break; final byte[] hash = decoder.decodeOctetString();
String typeId = decoder.decodeObjectIdentifier(); byte[] encodedValue = decoder.drainElement(); decoder.endSequence(); generalName = new OtherName(typeId, encodedValue); break out; decoder.endSequence(); return generalNames;
trustedAuthorities = EntityUtil.decodeTrustedAuthorities(decoder); decoder.endSequence(); } catch (ASN1Exception e) { throw saslEntity.mechInvalidServerMessageWithCause(e).toSaslException(); decoder.skipElement(); byte[] serverSignature = decoder.decodeBitString(); decoder.endSequence(); throw saslEntity.mechUnableToVerifyServerSignature(e).toSaslException(); decoder.endSequence(); } catch (ASN1Exception e) { throw saslEntity.mechInvalidServerMessageWithCause(e).toSaslException();
decoder.skipElement(); byte[] clientSignature = decoder.decodeBitString(); decoder.endSequence(); throw saslEntity.mechUnableToVerifyClientSignature(e).toSaslException(); decoder.endSequence(); } catch (ASN1Exception e) { throw saslEntity.mechInvalidClientMessageWithCause(e).toSaslException();
/** * 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); } } }
byte[] r = derDecoder.drainElementValue(); byte[] s = derDecoder.drainElementValue(); derDecoder.endSequence(); int rLength = r.length; int sLength = s.length;
byte[] r = derDecoder.drainElementValue(); byte[] s = derDecoder.drainElementValue(); derDecoder.endSequence(); int rLength = r.length; int sLength = s.length;
byte[] r = derDecoder.drainElementValue(); byte[] s = derDecoder.drainElementValue(); derDecoder.endSequence(); int rLength = r.length; int sLength = s.length;
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
decoder.endSequence(); return trustedAuthorities;
decoder.endSequence(); return trustedAuthorities;
decoder.endSequence(); return trustedAuthorities;