Re: Re: Re: Re: why publickey sequence use DLSequence in CMP cr-CertTemplate entity ?

J Gsealy <[email protected]> Thu, 23 May 2019 08:17:23 +0000
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <MN2PR07MB598442194CE4796B0D9AE349B3010@MN2PR07MB5984.namprd07.prod.outlook.com>
Hi team,

Now I know different between either sequence, but I found another thing.
When I build CertTemplate entity use CertTemplateBuilder Class, I found outside SubjectPublickeyInfo there none sequence to wrap it.

 [cid:_Foxmail.1@36bfc8d4-6a7f-03f9-b97a-74ee8a719f88]

Maybe this not specification, should add a sequence outside SubjectPublickeyInfo? if right , How to add it ?

thanks,
Gsealy

From: David Hook<mailto:[email protected]>
Date: 2019-05-23 13:46
To: dev-crypto<mailto:[email protected]>
Subject: Re: [dev-crypto] Re: Re: why publickey sequence use DLSequence in CMP cr-CertTemplate entity ?

A DLSequence and a DERSequence generally mean the same thing. Either can be used to produce a DER encoding as well. The difference is that on reading you can't explicitly tell if you're parsing DER data or definite-length data. The DLSequence is used to prevent things that have been parsed accidentally getting DER encoded when they shouldn't be.

Regards,

David

On 23/5/19 11:45 am, J Gsealy wrote:
Hi Matti,

I was build a EC Keypair use "sm2p256v1" curve. And use bellow method to convert it

ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("sm2p256v1");
KeyPairGenerator kp = helper.createKeyPairGenerator("EC");
kp.initialize(ecGenParameterSpec);
return kp.generateKeyPair();

CertificateRequestMessageBuilder msgBuilder = new CertificateRequestMessageBuilder(this.certReqId);
// add PublicKey
final SubjectPublicKeyInfo keyInfo = SubjectPublicKeyInfo.getInstance(this.publicKey.getEncoded());
msgBuilder.setPublicKey(keyInfo);


Is publickey not encode to DER?

Thanks,
Gsealy

From: Matti Aarnio [via Bouncy Castle]<mailto:[email protected]>
Date: 2019-05-23 01:17
To: Gsealy<mailto:[email protected]>
Subject: Re: why publickey sequence use DLSequence in CMP cr-CertTemplate entity ?
Hi Gsealy,

That depends on the SubjectPublicKeyInfo object you give to the CertificateRequestMessageBuilder.setPublicKey(spki) method.
How did you create it?

BR, Matti


On 5/22/19 3:44 PM, J Gsealy wrote:
Hi team,

I know CMP use DER encode and post by "application/pkixcmp" Content-Type.

I use BC CertificateRequestMessageBuilder class to create a cr(CertReqMessages) request, I found PublicKey entity is package by a DLSequence object

(use sm2), not Vector or DERSEquence (see attachment base64 text in "ECsm2req.txt")

[http://bouncy-castle.1462172.n4.nabble.com/attachment/4659621/0/DLSequence.png]

But my simple request text was use DERSequence(use RSA) (see attachment base64 text in "RSAreq.txt")

[http://bouncy-castle.1462172.n4.nabble.com/attachment/4659621/1/DERSequence.png]

use DLSequence is right? and what's different with others encode type(BER/DER)?

Thanks,
Gsealy



________________________________
If you reply to this email, your message will be added to the discussion below:
http://bouncy-castle.1462172.n4.nabble.com/why-publickey-sequence-use-DLSequence-in-CMP-cr-CertTemplate-entity-tp4659620p4659621.html<https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbouncy-castle.1462172.n4.nabble.com%2Fwhy-publickey-sequence-use-DLSequence-in-CMP-cr-CertTemplate-entity-tp4659620p4659621.html&data=02%7C01%7C%7Ce01d6ffeaa4f40290dd608d6df420c1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636941872102102217&sdata=e6YqvJpfy7sFrypTUuhUAffN8EKDhyYDshtpSrB3nxw%3D&reserved=0>
To start a new topic under Bouncy Castle - Dev, email [email protected]<mailto:[email protected]>
To unsubscribe from Bouncy Castle - Dev, click here<https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbouncy-castle.1462172.n4.nabble.com%2Ftemplate%2FNamlServlet.jtp%3Fmacro%3Dunsubscribe_by_code%26node%3D1462173%26code%3Damlhb2ppbmd3ZWkxMDAxQGhvdG1haWwuY29tfDE0NjIxNzN8NzIyNDYzNTY3&data=02%7C01%7C%7Ce01d6ffeaa4f40290dd608d6df420c1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636941872102112228&sdata=JxDAYl9KxON%2FkfbpbRz5QuxtV%2FhYLPKWGpLLScAszII%3D&reserved=0>.
NAML<https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbouncy-castle.1462172.n4.nabble.com%2Ftemplate%2FNamlServlet.jtp%3Fmacro%3Dmacro_viewer%26id%3Dinstant_html%2521nabble%253Aemail.naml%26base%3Dnabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace%26breadcrumbs%3Dnotify_subscribers%2521nabble%253Aemail.naml-instant_emails%2521nabble%253Aemail.naml-send_instant_email%2521nabble%253Aemail.naml&data=02%7C01%7C%7Ce01d6ffeaa4f40290dd608d6df420c1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636941872102132243&sdata=QfzuBD3g7QyxFgqBzzLdx2aAK8HGhjsWKgWY3Br9eb0%3D&reserved=0>
InsertPic_.png (image/png, 3.6 KB) - not displayed
cmp_base64.txt (application/octet-stream, 1016 B)
MIIC9DCCAj4CAQGkFDASMRAwDgYDVQQDDAd0ZXN0MDAypBMwETEPMA0GA1UEAwwGY2Ffc20ypYIBBASCAQBL0xikaxWz2R4edb2hF1aKe5VlsZw5fIQsGpZIcCsUE5Z3LRIfKoYVZi7FXISdFhJpjY4HTwrCwNbhYFa1WTUqoXZMtKHzKvc/XGAK1gxzOHODKzVuG2nwXpa/w16MtmleE6RDuvdh0sEQAMOQViWQRQkcnERCIZHmNaKbluAFso8e8rFaN/4rjxGpHC0T35ss04LhcXNct575Q1R1UqJ4Z2L+fw0tWXqEL44NVHtnDWLZ2UH7QoFLdeAbqSNhEJMjB6D3R2+3Ynx4RTEyB2l+IQaim37KU4kVQeQ2B1O+lb5078hmFjmABRIDpU9oZ/3qO2gJNoAU2/0HErwPl3WbpoIBBASCAQBIEGerLivgGPBpvjspcdkti2ITK3YXfsvsYMdvf5VHAGh9cDvyfIZxyGQu6mkcNH2vVlLCt5jnyWtkU1Fand+zNgajm0iP20HM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