Skip to content

Commit

Permalink
Add smime capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey authored and mmerklinger committed Sep 13, 2024
1 parent bc3d4b0 commit 634f485
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pynitrokey/cli/nk3/piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import click
import cryptography
from asn1crypto import x509
from asn1crypto.core import ParsableOctetString
from asn1crypto.csr import CertificationRequest, CertificationRequestInfo
from asn1crypto.keys import PublicKeyInfo
from click_aliases import ClickAliasedGroup
Expand Down Expand Up @@ -404,6 +405,37 @@ def generate_key(
for subject in subject_name
]

# SEQUENCE
# SEQUENCE
# OBJECT :aes-256-cbc
# SEQUENCE
# OBJECT :id-aes256-wrap
# SEQUENCE
# OBJECT :aes-192-cbc
# SEQUENCE
# OBJECT :id-aes192-wrap
# SEQUENCE
# OBJECT :aes-128-cbc
# SEQUENCE
# OBJECT :id-aes128-wrap
# SEQUENCE
# OBJECT :des-ede3-cbc
# SEQUENCE
# OBJECT :des-cbc
# SEQUENCE
# OBJECT :rc2-cbc
# INTEGER :80
# SEQUENCE
# OBJECT :rc4
# INTEGER :0200
smime_extension = ParsableOctetString(
value=bytes(
bytearray.fromhex(
"308183300B060960864801650304012A300B060960864801650304012D300B0609608648016503040116300B0609608648016503040119300B0609608648016503040102300B0609608648016503040105300A06082A864886F70D0307300706052B0E030207300E06082A864886F70D030202020080300E06082A864886F70D030402020200"
)
)
)

extensions = [
{
"extn_id": "basic_constraints",
Expand All @@ -422,6 +454,11 @@ def generate_key(
["client_auth", "microsoft_smart_card_logon"]
),
},
{
"extn_id": "1.2.840.113549.1.9.15",
"critical": False,
"extn_value": smime_extension,
},
]

if subject_alt_name_upn is not None:
Expand Down

0 comments on commit 634f485

Please sign in to comment.