Skip to content

PKCS#7 signed data and custom authenticatedAttributes / OIDs #400

@NuSkooler

Description

@NuSkooler

Is there a way to add custom (e.g. not known to node-forge) authenticated attributes to a PKCS#7 signed package?

I'm attempting the following, but see "empty" results when I openssl asn1parse ... the output:

const signed = forge.pkcs7.createSignedData();

signed.addSigner({
    key                 : privateKey,
    certificate             : cert,
    digestAlgorithm     : forge.pki.oids.sha1,
    authenticatedAttributes : [
        {
            type    : forge.pki.oids.contentType,
            value   : forge.pki.oids.data
        },
        {
            type: forge.pki.oids.messageDigest              
        },
        {
            type: forge.pki.oids.signingTime,               
        },
        //  :TODO:
        //  "The transactionID SHOULD be the MD5 hash of the public key from the
        //  request, encoded as a PrintableString"
        {
            name    : 'transactionID',
            type    : '2.16.840.1.113733.1.9.7',
            value   : '2dc41c4aa005263394db2c91904fd183',

        },
        {
            name    : 'messageType',
            type    : '2.16.840.1.113733.1.9.2',
            value   : '3',  //  CertRep         
        },
        {
            name    : 'senderNonce',
            type    : '2.16.840.1.113733.1.9.5',
            value   : '2528804744729265',
        },
        {
            name    : 'responderNonce',
            type    : '2.16.840.1.113733.1.9.6',
            value   : '9523024721942548',
        },  
        {
            name    : 'pkiStatus',
            type    : '2.16.840.1.113733.1.9.3',
            value   : '0',  //  SUCCESS
        }
    ] 
});

signed.content = forge.asn1.toDer(enveloped.toAsn1());
signed.sign();  

The OIDs in question are related to SCEP (See e.g. http://www.cisco.com/c/en/us/support/docs/security-vpn/public-key-infrastructure-pki/116167-technote-scep-00.html)

Example fragment dump from openssl asn1parse ...:

1579:d=6  hl=2 l=  14 cons: SEQUENCE          
 1581:d=7  hl=2 l=  10 prim: OBJECT            :2.16.840.1.113733.1.9.7
 1593:d=7  hl=2 l=   0 cons: SET               

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions