cryptography icon indicating copy to clipboard operation
cryptography copied to clipboard

Key Attributes extraction from RSAPrivateKey Object

Open dohyungp opened this issue 3 years ago • 3 comments

Hello, Team! First of all, I am a newbie of cryptography and the cryptography library. 😅

I am trying to extract OID of Key Attributes and the Bit String.

I can get the value when I use openssl command like,

openssl pkcs12 -in pkcs12.pfx -nocerts -nodes -out pkcs12.key

and the output is,

Bag Attributes
    localKeyID: 01 00 00 00 
Key Attributes
    1.2.410.200004.10.1.1.3: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
-----BEGIN PRIVATE KEY-----

Finally I can get 1.2.410.200004.10.1.1.3 and the value.

But when I trying to extract the value in python and cryptography library(like below),

prikey, pub_cert, additionals = pkcs12.load_key_and_certificates(data=p12_data, password=prikey_password)

# oid_value = prikey.some_method.get_oid("1.2.3...")

I can't extract that.

How can the OID from cryptography library and the value?

Warm regards,

dohyungp avatar Jun 30 '21 15:06 dohyungp

We currently do not have an API for extracitng key attributes from a PKCS#12 archive, so this would be a feature request.

On Wed, Jun 30, 2021 at 11:13 AM Dohyung Park @.***> wrote:

Hello, Team! First of all, I am a newbie of cryptography and the cryptography library. 😅

I am trying to extract OID of Key Attributes and the Bit String.

I can get the value when I use openssl command like,

openssl pkcs12 -in pkcs12.pfx -nocerts -nodes -out pkcs12.key

and the key make a output like,

Bag Attributes

localKeyID: 01 00 00 00

Key Attributes

1.2.410.200004.10.1.1.3: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA

-----BEGIN PRIVATE KEY-----

Finally I can get 1.2.410.200004.10.1.1.3 and the value.

But when I trying to extract the value in python and cryptography library(like below),

prikey, pub_cert, additionals = pkcs12.load_key_and_certificates(data=p12_data, password=prikey_password)

oid_value = prikey.some_method.get_oid("1.2.3...")

I can't extract that.

How can the OID from cryptography library and the value?

Warm regards,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pyca/cryptography/issues/6149, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAGBEWL5GKWXVFIA2HIUDTVMYDNANCNFSM47SRSO4A .

-- All that is necessary for evil to succeed is for good people to do nothing.

alex avatar Jun 30 '21 15:06 alex

Hello team, are there any updates on this? This API would be very useful.

Kind regards

felixZdi avatar Jul 18 '22 10:07 felixZdi

There is no one actively working on this, although we are happy to review code and talk about proposed APIs.

reaperhulk avatar Jul 18 '22 10:07 reaperhulk