Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indefinite length in BER encoding for PKCS#7 #478

Open
tysonite opened this issue Feb 1, 2017 · 0 comments
Open

Indefinite length in BER encoding for PKCS#7 #478

tysonite opened this issue Feb 1, 2017 · 0 comments

Comments

@tysonite
Copy link

tysonite commented Feb 1, 2017

As per RFC 2315, various PKCS#7 content types shall be encoded using indefinite length form. Right now, it is not possible to choose such type of BER length encoding. For instance, PKCS#7 objects created by the library (with enveloped-data) can't be decoded by Microsoft Outlook (S/MIME format) because of that.

Here is the code used to create PKCS#7:

    // create a p7 enveloped message
    var p7 = forge.pkcs7.createEnvelopedData();

    // add recipient's certificate
    p7.addRecipient(cert);
    
    // set content
    p7.content = forge.util.createBuffer();
    p7.content.putString(content);

    // encrypt
    p7.encrypt();

    // get DER bytes (!!!Definite length form is used!!!)
    forge.asn1.toDer(p7.toAsn1()).getBytes();

I expect that forge.asn1.toDer generates DER data with indefinite length form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant