diff options
Diffstat (limited to 'src/libstrongswan/plugins/pkcs1')
-rw-r--r-- | src/libstrongswan/plugins/pkcs1/Makefile.am | 2 | ||||
-rw-r--r-- | src/libstrongswan/plugins/pkcs1/Makefile.in | 8 | ||||
-rw-r--r-- | src/libstrongswan/plugins/pkcs1/pkcs1_encoder.c | 47 |
3 files changed, 42 insertions, 15 deletions
diff --git a/src/libstrongswan/plugins/pkcs1/Makefile.am b/src/libstrongswan/plugins/pkcs1/Makefile.am index 5dbc4e9c2..d579531ef 100644 --- a/src/libstrongswan/plugins/pkcs1/Makefile.am +++ b/src/libstrongswan/plugins/pkcs1/Makefile.am @@ -2,7 +2,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/libstrongswan AM_CFLAGS = \ - -rdynamic + $(PLUGIN_CFLAGS) if MONOLITHIC noinst_LTLIBRARIES = libstrongswan-pkcs1.la diff --git a/src/libstrongswan/plugins/pkcs1/Makefile.in b/src/libstrongswan/plugins/pkcs1/Makefile.in index c563806ee..edaa8c3eb 100644 --- a/src/libstrongswan/plugins/pkcs1/Makefile.in +++ b/src/libstrongswan/plugins/pkcs1/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.13.3 from Makefile.am. +# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. @@ -265,6 +265,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OPENSSL_LIB = @OPENSSL_LIB@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -283,6 +284,7 @@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PLUGIN_CFLAGS = @PLUGIN_CFLAGS@ PTHREADLIB = @PTHREADLIB@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ @@ -310,6 +312,7 @@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +aikgen_plugins = @aikgen_plugins@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -401,6 +404,7 @@ srcdir = @srcdir@ starter_plugins = @starter_plugins@ strongswan_conf = @strongswan_conf@ strongswan_options = @strongswan_options@ +swanctldir = @swanctldir@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ t_plugins = @t_plugins@ @@ -415,7 +419,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/libstrongswan AM_CFLAGS = \ - -rdynamic + $(PLUGIN_CFLAGS) @MONOLITHIC_TRUE@noinst_LTLIBRARIES = libstrongswan-pkcs1.la @MONOLITHIC_FALSE@plugin_LTLIBRARIES = libstrongswan-pkcs1.la diff --git a/src/libstrongswan/plugins/pkcs1/pkcs1_encoder.c b/src/libstrongswan/plugins/pkcs1/pkcs1_encoder.c index 2c3bf6e7c..905f14c88 100644 --- a/src/libstrongswan/plugins/pkcs1/pkcs1_encoder.c +++ b/src/libstrongswan/plugins/pkcs1/pkcs1_encoder.c @@ -30,8 +30,8 @@ static bool build_pub(chunk_t *encoding, va_list args) CRED_PART_RSA_PUB_EXP, &e, CRED_PART_END)) { *encoding = asn1_wrap(ASN1_SEQUENCE, "mm", - asn1_wrap(ASN1_INTEGER, "c", n), - asn1_wrap(ASN1_INTEGER, "c", e)); + asn1_integer("c", n), + asn1_integer("c", e)); return TRUE; } return FALSE; @@ -51,8 +51,29 @@ static bool build_pub_info(chunk_t *encoding, va_list args) asn1_algorithmIdentifier(OID_RSA_ENCRYPTION), asn1_bitstring("m", asn1_wrap(ASN1_SEQUENCE, "mm", - asn1_wrap(ASN1_INTEGER, "c", n), - asn1_wrap(ASN1_INTEGER, "c", e)))); + asn1_integer("c", n), + asn1_integer("c", e)))); + return TRUE; + } + return FALSE; +} + +/** + * Encode the RSA modulus of a public key only + */ +static bool build_pub_modulus(chunk_t *encoding, va_list args) +{ + chunk_t n; + + if (cred_encoding_args(args, CRED_PART_RSA_MODULUS, &n, CRED_PART_END)) + { + /* remove preceding zero bytes */ + while (n.len > 0 && *n.ptr == 0x00) + { + n.ptr++; + n.len--; + } + *encoding = chunk_clone(n); return TRUE; } return FALSE; @@ -73,14 +94,14 @@ static bool build_priv(chunk_t *encoding, va_list args) { *encoding = asn1_wrap(ASN1_SEQUENCE, "cmmssssss", ASN1_INTEGER_0, - asn1_wrap(ASN1_INTEGER, "c", n), - asn1_wrap(ASN1_INTEGER, "c", e), - asn1_wrap(ASN1_INTEGER, "c", d), - asn1_wrap(ASN1_INTEGER, "c", p), - asn1_wrap(ASN1_INTEGER, "c", q), - asn1_wrap(ASN1_INTEGER, "c", exp1), - asn1_wrap(ASN1_INTEGER, "c", exp2), - asn1_wrap(ASN1_INTEGER, "c", coeff)); + asn1_integer("c", n), + asn1_integer("c", e), + asn1_integer("c", d), + asn1_integer("c", p), + asn1_integer("c", q), + asn1_integer("c", exp1), + asn1_integer("c", exp2), + asn1_integer("c", coeff)); return TRUE; } return FALSE; @@ -151,6 +172,8 @@ bool pkcs1_encoder_encode(cred_encoding_type_t type, chunk_t *encoding, return build_pub(encoding, args); case PUBKEY_SPKI_ASN1_DER: return build_pub_info(encoding, args); + case PUBKEY_RSA_MODULUS: + return build_pub_modulus(encoding, args); case PRIVKEY_ASN1_DER: return build_priv(encoding, args); default: |