Challenge (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1.cmp

## Class Challenge

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.cmp.Challenge

- All Implemented Interfaces:
    ASN1Encodable, Encodable

      public class Challenge
      extends ASN1Object

       Challenge ::= SEQUENCE {
                owf                 AlgorithmIdentifier  OPTIONAL,

                -- MUST be present in the first Challenge; MAY be omitted in
                -- any subsequent Challenge in POPODecKeyChallContent (if
                -- omitted, then the owf used in the immediately preceding
                -- Challenge is to be used).

                witness             OCTET STRING,
                -- the result of applying the one-way function (owf) to a
                -- randomly-generated INTEGER, A.  [Note that a different
                -- INTEGER MUST be used for each Challenge.]
                challenge           OCTET STRING   -- deprecated
                -- the encryption (under the public key for which the cert.
                -- request is being made) of Rand
                encryptedRand [0] EnvelopedData OPTIONAL
           }

           Rand ::= SEQUENCE {
                 int      INTEGER, -- the randomly-generated INTEGER A (above)
                 sender   GeneralName -- the sender's name (as included in PKIHeader)
            }

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Challenge.Rand` Rand is the inner type

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Challenge(AlgorithmIdentifier owf, byte[] witness, byte[] challenge)`
    `Challenge(AlgorithmIdentifier owf, byte[] witness, EnvelopedData encryptedRand)`
    `Challenge(byte[] witness, byte[] challenge)`
    `Challenge(byte[] witness, EnvelopedData encryptedRand)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getChallenge()`
    `EnvelopedData` | `getEncryptedRand()`
    `static Challenge` | `getInstance(java.lang.Object o)`
    `AlgorithmIdentifier` | `getOwf()`
    `byte[]` | `getWitness()`
    `boolean` | `isEncryptedRand()`
    `ASN1Primitive` | `toASN1Primitive()` Challenge ::= SEQUENCE { owf AlgorithmIdentifier OPTIONAL, -- MUST be present in the first Challenge; MAY be omitted in -- any subsequent Challenge in POPODecKeyChallContent (if -- omitted, then the owf used in the immediately preceding -- Challenge is to be used).

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

      `encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Challenge

          public Challenge(byte[] witness,
                           byte[] challenge)

    - #### Challenge

          public Challenge(byte[] witness,
                           EnvelopedData encryptedRand)

    - #### Challenge

          public Challenge(AlgorithmIdentifier owf,
                           byte[] witness,
                           byte[] challenge)

    - #### Challenge

          public Challenge(AlgorithmIdentifier owf,
                           byte[] witness,
                           EnvelopedData encryptedRand)

  - ### Method Detail

    - #### getInstance

          public static Challenge getInstance(java.lang.Object o)

    - #### getOwf

          public AlgorithmIdentifier getOwf()

    - #### getWitness

          public byte[] getWitness()

    - #### isEncryptedRand

          public boolean isEncryptedRand()

    - #### getChallenge

          public byte[] getChallenge()

    - #### getEncryptedRand

          public EnvelopedData getEncryptedRand()

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

           Challenge ::= SEQUENCE {
                    owf                 AlgorithmIdentifier  OPTIONAL,

                    -- MUST be present in the first Challenge; MAY be omitted in
                    -- any subsequent Challenge in POPODecKeyChallContent (if
                    -- omitted, then the owf used in the immediately preceding
                    -- Challenge is to be used).

                    witness             OCTET STRING,
                    -- the result of applying the one-way function (owf) to a
                    -- randomly-generated INTEGER, A.  [Note that a different
                    -- INTEGER MUST be used for each Challenge.]
                    challenge           OCTET STRING   -- deprecated
                    -- the encryption (under the public key for which the cert.
                    -- request is being made) of Rand
                    encryptedRand [0] EnvelopedData OPTIONAL
               }

               Rand ::= SEQUENCE {
                     int      INTEGER, -- the randomly-generated INTEGER A (above)
                     sender   GeneralName -- the sender's name (as included in PKIHeader)
                }

      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        a basic ASN.1 object representation.