Skip to content

Commit

Permalink
export-object: Recover public key from algorithm specific attributes
Browse files Browse the repository at this point in the history
Some tokens such as SoftHSMv2 omits CKA_PUBLIC_KEY_INFO when it can be
derived from algorithm specific attributes, such as CKA_MODULUS and
CKA_PUBLIC_EXPONENT for RSA.  This adds support for it if libtasn1 is
available at compile time.

Signed-off-by: Daiki Ueno <[email protected]>
  • Loading branch information
ueno committed Sep 22, 2023
1 parent 66674c2 commit 9d7bd7c
Show file tree
Hide file tree
Showing 11 changed files with 743 additions and 59 deletions.
3 changes: 3 additions & 0 deletions common/oid.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,7 @@ static const unsigned char P11_OID_RESERVED_PURPOSE[] =
{ 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x99, 0x77, 0x06, 0x0a, 0x10 };
static const char P11_OID_RESERVED_PURPOSE_STR[] = "1.3.6.1.4.1.3319.6.10.16";

static const char P11_OID_PKIX1_RSA_STR[] = "1.2.840.113549.1.1.1";
static const char P11_OID_PKIX1_EC_STR[] = "1.2.840.10045.2.1";

#endif
4 changes: 4 additions & 0 deletions common/pkix.asn
Original file line number Diff line number Diff line change
Expand Up @@ -537,4 +537,8 @@ ProxyPolicy ::= SEQUENCE {
policyLanguage OBJECT IDENTIFIER,
policy OCTET STRING OPTIONAL }

RSAPublicKey ::= SEQUENCE {
modulus INTEGER,
publicExponent INTEGER }

END
23 changes: 22 additions & 1 deletion p11-kit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ p11_kit_p11_kit_LDADD = \
$(LTLIBINTL) \
$(NULL)

if WITH_ASN1
p11_kit_p11_kit_CFLAGS += $(LIBTASN1_CFLAGS)
p11_kit_p11_kit_LDADD += libp11-asn1.la $(LIBTASN1_LIBS)
endif

if WITH_BASH_COMPLETION
bashcomp_DATA += bash-completion/p11-kit
endif
Expand Down Expand Up @@ -312,6 +317,11 @@ p11_kit_p11_kit_testable_CFLAGS = \
$(COMMON_CFLAGS) \
$(NULL)

if WITH_ASN1
p11_kit_p11_kit_testable_CFLAGS += $(LIBTASN1_CFLAGS)
p11_kit_p11_kit_testable_LDADD += libp11-asn1.la $(LIBTASN1_LIBS)
endif

private_PROGRAMS += p11-kit/p11-kit-remote

p11_kit_p11_kit_remote_SOURCES = \
Expand Down Expand Up @@ -416,6 +426,11 @@ sh_tests += \
p11-kit/test-lists.sh \
p11-kit/test-server.sh \
$(NULL)

if WITH_ASN1
sh_tests += p11-kit/test-export-public.sh
endif

endif

test_conf_SOURCES = p11-kit/test-conf.c
Expand Down Expand Up @@ -522,7 +537,8 @@ check_LTLIBRARIES += \
mock-eight.la \
mock-nine.la \
mock-ten.la \
mock-eleven.la
mock-eleven.la \
mock-twelve.la

mock_one_la_SOURCES = p11-kit/mock-module-ep.c
mock_one_la_LIBADD = libp11-test.la libp11-common.la
Expand Down Expand Up @@ -587,6 +603,10 @@ mock_eleven_la_SOURCES = p11-kit/mock-module-ep9.c
mock_eleven_la_LDFLAGS = $(mock_one_la_LDFLAGS)
mock_eleven_la_LIBADD = $(mock_one_la_LIBADD)

mock_twelve_la_SOURCES = p11-kit/mock-module-ep10.c
mock_twelve_la_LDFLAGS = $(mock_one_la_LDFLAGS)
mock_twelve_la_LIBADD = $(mock_one_la_LIBADD)

EXTRA_DIST += \
p11-kit/fixtures \
p11-kit/templates \
Expand All @@ -597,4 +617,5 @@ EXTRA_DIST += \
p11-kit/test-lists.sh \
p11-kit/test-messages.sh \
p11-kit/test-server.sh \
p11-kit/test-export-public.sh \
$(NULL)
Loading

0 comments on commit 9d7bd7c

Please sign in to comment.