/** * Encode an {@code AlgorithmIdentifier} using the given DER encoder. The ASN.1 definition of {@code AlgorithmIdentifier} is: * * <pre> * AlgorithmIdentifier {ALGORITHM:IOSet } ::= SEQUENCE { * algorithm ALGORITHM.&id({IOSet}), * parameters ALGORITHM.&Type({IOSet}{{@literal @}algorithm}) OPTIONAL * } * </pre> * * @param encoder the DER encoder */ private void encodeAlgorithmIdentifier(final DEREncoder encoder) { encoder.startSequence(); encoder.encodeObjectIdentifier(signatureAlgorithmOid); if (signingKey.getAlgorithm().equals("RSA")) { // Include the NULL parameter for RSA based signature algorithms only, as per RFC 3279 (http://www.ietf.org/rfc/rfc3279) encoder.encodeNull(); } encoder.endSequence(); }
/** * <p> * Encode an {@code AlgorithmIdentifier} without any parameters using the given * DER encoder and object identifier, where {@code AlgorithmIdentifier} is defined as: * * <pre> * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * </pre> * </p> * * @param encoder the DER encoder * @param objectIdentifier the object identifier for the algorithm * @param omitParametersField {@code true} if the parameters field should be ommitted in * the encoding and {@code false} otherwise * @throws ASN1Exception if the given object identifier is invalid */ public static void encodeAlgorithmIdentifier(final DEREncoder encoder, String objectIdentifier, boolean omitParametersField) throws ASN1Exception { encoder.startSequence(); encoder.encodeObjectIdentifier(objectIdentifier); if (!omitParametersField) { encoder.encodeNull(); } encoder.endSequence(); }
/** * Encode an {@code AlgorithmIdentifier} using the given DER encoder. The ASN.1 definition of {@code AlgorithmIdentifier} is: * * <pre> * AlgorithmIdentifier {ALGORITHM:IOSet } ::= SEQUENCE { * algorithm ALGORITHM.&id({IOSet}), * parameters ALGORITHM.&Type({IOSet}{{@literal @}algorithm}) OPTIONAL * } * </pre> * * @param encoder the DER encoder */ private void encodeAlgorithmIdentifier(final DEREncoder encoder) { encoder.startSequence(); encoder.encodeObjectIdentifier(signatureAlgorithmOid); if (signingKey.getAlgorithm().equals("RSA")) { // Include the NULL parameter for RSA based signature algorithms only, as per RFC 3279 (http://www.ietf.org/rfc/rfc3279) encoder.encodeNull(); } encoder.endSequence(); }
/** * Encode an {@code AlgorithmIdentifier} using the given DER encoder. The ASN.1 definition of {@code AlgorithmIdentifier} is: * * <pre> * AlgorithmIdentifier {ALGORITHM:IOSet } ::= SEQUENCE { * algorithm ALGORITHM.&id({IOSet}), * parameters ALGORITHM.&Type({IOSet}{{@literal @}algorithm}) OPTIONAL * } * </pre> * * @param encoder the DER encoder */ private void encodeAlgorithmIdentifier(final DEREncoder encoder) { encoder.startSequence(); encoder.encodeObjectIdentifier(signatureAlgorithmOid); if (signingKey.getAlgorithm().equals("RSA")) { // Include the NULL parameter for RSA based signature algorithms only, as per RFC 3279 (http://www.ietf.org/rfc/rfc3279) encoder.encodeNull(); } encoder.endSequence(); }
/** * Encode an {@code AlgorithmIdentifier} using the given DER encoder. The ASN.1 definition of {@code AlgorithmIdentifier} is: * * <pre> * AlgorithmIdentifier {ALGORITHM:IOSet } ::= SEQUENCE { * algorithm ALGORITHM.&id({IOSet}), * parameters ALGORITHM.&Type({IOSet}{{@literal @}algorithm}) OPTIONAL * } * </pre> * * @param encoder the DER encoder */ private void encodeAlgorithmIdentifier(final DEREncoder encoder) { encoder.startSequence(); encoder.encodeObjectIdentifier(signatureAlgorithmOid); if (signingKey.getAlgorithm().equals("RSA")) { // Include the NULL parameter for RSA based signature algorithms only, as per RFC 3279 (http://www.ietf.org/rfc/rfc3279) encoder.encodeNull(); } encoder.endSequence(); }
/** * <p> * Encode an {@code AlgorithmIdentifier} without any parameters using the given * DER encoder and object identifier, where {@code AlgorithmIdentifier} is defined as: * * <pre> * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * </pre> * </p> * * @param encoder the DER encoder * @param objectIdentifier the object identifier for the algorithm * @param omitParametersField {@code true} if the parameters field should be ommitted in * the encoding and {@code false} otherwise * @throws ASN1Exception if the given object identifier is invalid */ public static void encodeAlgorithmIdentifier(final DEREncoder encoder, String objectIdentifier, boolean omitParametersField) throws ASN1Exception { encoder.startSequence(); encoder.encodeObjectIdentifier(objectIdentifier); if (!omitParametersField) { encoder.encodeNull(); } encoder.endSequence(); }
/** * <p> * Encode an {@code AlgorithmIdentifier} without any parameters using the given * DER encoder and object identifier, where {@code AlgorithmIdentifier} is defined as: * * <pre> * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * </pre> * </p> * * @param encoder the DER encoder * @param objectIdentifier the object identifier for the algorithm * @param omitParametersField {@code true} if the parameters field should be ommitted in * the encoding and {@code false} otherwise * @throws ASN1Exception if the given object identifier is invalid */ public static void encodeAlgorithmIdentifier(final DEREncoder encoder, String objectIdentifier, boolean omitParametersField) throws ASN1Exception { encoder.startSequence(); encoder.encodeObjectIdentifier(objectIdentifier); if (!omitParametersField) { encoder.encodeNull(); } encoder.endSequence(); }
/** * <p> * Encode an {@code AlgorithmIdentifier} without any parameters using the given * DER encoder and object identifier, where {@code AlgorithmIdentifier} is defined as: * * <pre> * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * </pre> * </p> * * @param encoder the DER encoder * @param objectIdentifier the object identifier for the algorithm * @param omitParametersField {@code true} if the parameters field should be ommitted in * the encoding and {@code false} otherwise * @throws ASN1Exception if the given object identifier is invalid */ public static void encodeAlgorithmIdentifier(final DEREncoder encoder, String objectIdentifier, boolean omitParametersField) throws ASN1Exception { encoder.startSequence(); encoder.encodeObjectIdentifier(objectIdentifier); if (!omitParametersField) { encoder.encodeNull(); } encoder.endSequence(); }