Search in sources :

Example 1 with Asn1ObjectIdentifier

use of de.rub.nds.asn1.model.Asn1ObjectIdentifier in project TLS-Scanner by tls-attacker.

the class OcspProbe method prepareNonceExtension.

private byte[] prepareNonceExtension() {
    Asn1Sequence innerExtensionSequence = new Asn1Sequence();
    Asn1ObjectIdentifier oid = new Asn1ObjectIdentifier();
    oid.setValue(NONCE.getOID());
    Asn1Sequence extensionSequence = new Asn1Sequence();
    innerExtensionSequence.addChild(oid);
    Asn1EncapsulatingOctetString encapsulatingOctetString = new Asn1EncapsulatingOctetString();
    // Nonce
    Asn1PrimitiveOctetString nonceOctetString = new Asn1PrimitiveOctetString();
    Random rand = new Random(STAPLED_NONCE_RANDOM_SEED);
    BigInteger nonce = new BigInteger(STAPLED_NONCE_RANDOM_BIT_LENGTH, rand);
    nonceOctetString.setValue(nonce.toByteArray());
    encapsulatingOctetString.addChild(nonceOctetString);
    innerExtensionSequence.addChild(encapsulatingOctetString);
    extensionSequence.addChild(innerExtensionSequence);
    List<Asn1Encodable> asn1Encodables = new LinkedList<>();
    asn1Encodables.add(extensionSequence);
    Asn1Encoder asn1Encoder = new Asn1Encoder(asn1Encodables);
    return asn1Encoder.encode();
}
Also used : Random(java.util.Random) Asn1EncapsulatingOctetString(de.rub.nds.asn1.model.Asn1EncapsulatingOctetString) Asn1ObjectIdentifier(de.rub.nds.asn1.model.Asn1ObjectIdentifier) Asn1PrimitiveOctetString(de.rub.nds.asn1.model.Asn1PrimitiveOctetString) BigInteger(java.math.BigInteger) Asn1Sequence(de.rub.nds.asn1.model.Asn1Sequence) Asn1Encoder(de.rub.nds.asn1.encoder.Asn1Encoder) Asn1Encodable(de.rub.nds.asn1.Asn1Encodable) LinkedList(java.util.LinkedList)

Example 2 with Asn1ObjectIdentifier

use of de.rub.nds.asn1.model.Asn1ObjectIdentifier in project TLS-Scanner by RUB-NDS.

the class OcspProbe method prepareNonceExtension.

private byte[] prepareNonceExtension() {
    Asn1Sequence innerExtensionSequence = new Asn1Sequence();
    Asn1ObjectIdentifier oid = new Asn1ObjectIdentifier();
    oid.setValue(NONCE.getOID());
    Asn1Sequence extensionSequence = new Asn1Sequence();
    innerExtensionSequence.addChild(oid);
    Asn1EncapsulatingOctetString encapsulatingOctetString = new Asn1EncapsulatingOctetString();
    // Nonce
    Asn1PrimitiveOctetString nonceOctetString = new Asn1PrimitiveOctetString();
    Random rand = new Random(STAPLED_NONCE_RANDOM_SEED);
    BigInteger nonce = new BigInteger(STAPLED_NONCE_RANDOM_BIT_LENGTH, rand);
    nonceOctetString.setValue(nonce.toByteArray());
    encapsulatingOctetString.addChild(nonceOctetString);
    innerExtensionSequence.addChild(encapsulatingOctetString);
    extensionSequence.addChild(innerExtensionSequence);
    List<Asn1Encodable> asn1Encodables = new LinkedList<>();
    asn1Encodables.add(extensionSequence);
    Asn1Encoder asn1Encoder = new Asn1Encoder(asn1Encodables);
    return asn1Encoder.encode();
}
Also used : Random(java.util.Random) Asn1EncapsulatingOctetString(de.rub.nds.asn1.model.Asn1EncapsulatingOctetString) Asn1ObjectIdentifier(de.rub.nds.asn1.model.Asn1ObjectIdentifier) Asn1PrimitiveOctetString(de.rub.nds.asn1.model.Asn1PrimitiveOctetString) BigInteger(java.math.BigInteger) Asn1Sequence(de.rub.nds.asn1.model.Asn1Sequence) Asn1Encoder(de.rub.nds.asn1.encoder.Asn1Encoder) Asn1Encodable(de.rub.nds.asn1.Asn1Encodable) LinkedList(java.util.LinkedList)

Aggregations

Asn1Encodable (de.rub.nds.asn1.Asn1Encodable)2 Asn1Encoder (de.rub.nds.asn1.encoder.Asn1Encoder)2 Asn1EncapsulatingOctetString (de.rub.nds.asn1.model.Asn1EncapsulatingOctetString)2 Asn1ObjectIdentifier (de.rub.nds.asn1.model.Asn1ObjectIdentifier)2 Asn1PrimitiveOctetString (de.rub.nds.asn1.model.Asn1PrimitiveOctetString)2 Asn1Sequence (de.rub.nds.asn1.model.Asn1Sequence)2 BigInteger (java.math.BigInteger)2 LinkedList (java.util.LinkedList)2 Random (java.util.Random)2