What is the algorithm identifier when using AES in CBC mode with ISO 10126 padding inside of PKCS#7?

StackOverflow https://stackoverflow.com/questions/304658

Question

I want to use PKCS#7 as a container format for some encrypted, signed content and we need to use AES in CBC mode with ISO 10126 based padding. I can't seem to find a concrete reference to an algorithm identifier to use for this combination. I can invent my own but would then lose interoperability with other tools.

Was it helpful?

Solution

The padding mode does not need to be specified. This is true because PKCS#7 (like many other cryptographic containers) uses ASN.1/BER encoding. As the BER encoding contains the exact length of the message inside the padded plain text, the actual value of the padding doesn't matter.

OTHER TIPS

It turns out that the padding mode does not need to be specified, only the crypto algorithm matters.

I believe if you are using PKCS#7 as your format, the padding is dictated to be, well, "PKCS7" padding (n octets of value 'n', see RFC 2315, section 10.3.2).

The algorithm identifier(s) for AES/CBC are given in e.g. RFC 3565:

-- AES information object identifiers --

aes OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840)
               organization(1) gov(101) csor(3)_ nistAlgorithms(4)  1 }

-- AES using CBC-chaining mode for key sizes of 128, 192, 256

id-aes128-CBC OBJECT IDENTIFIER ::= { aes 2 }
id-aes192-CBC OBJECT IDENTIFIER ::= { aes 22 }
id-aes256-CBC OBJECT IDENTIFIER ::= { aes 42 }

So, e.g. the OID for 128-bit AES in CBC mode is 2.16.840.1.101.3.4.1.2

Technically, these are for CMS, which is essentially the updated PKCS#7.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top