From 1e60cd09b084add46037e24af6ab6b5b9c7de180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 10 Jul 2013 10:28:53 +0200 Subject: [PATCH] Expand oid_get_sig_alg() for ECDSA-based algs --- include/polarssl/oid.h | 30 ++++++++++++++++++++++++++++++ include/polarssl/pk.h | 3 +++ library/oid.c | 20 ++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/include/polarssl/oid.h b/include/polarssl/oid.h index a39055b06..0c3dab216 100644 --- a/include/polarssl/oid.h +++ b/include/polarssl/oid.h @@ -276,6 +276,36 @@ * iso(1) identified-organization(3) certicom(132) curve(0) 35 } */ #define OID_EC_GRP_SECP521R1 OID_CERTICOM "\x00\x23" +/* + * ECDSA signature identifers, from RFC 5480 + */ +#define OID_ANSI_X9_62_SIG OID_ANSI_X9_62 "\x04" /* signatures(4) */ +#define OID_ANSI_X9_62_SIG_SHA2 OID_ANSI_X9_62_SIG "\x03" /* ecdsa-with-SHA2(3) */ + +/* ecdsa-with-SHA1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) 1 } */ +#define OID_ECDSA_SHA1 OID_ANSI_X9_62_SIG "\x01" + +/* ecdsa-with-SHA224 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 1 } */ +#define OID_ECDSA_SHA224 OID_ANSI_X9_62_SIG_SHA2 "\x01" + +/* ecdsa-with-SHA256 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 2 } */ +#define OID_ECDSA_SHA256 OID_ANSI_X9_62_SIG_SHA2 "\x02" + +/* ecdsa-with-SHA384 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 3 } */ +#define OID_ECDSA_SHA384 OID_ANSI_X9_62_SIG_SHA2 "\x03" + +/* ecdsa-with-SHA512 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 4 } */ +#define OID_ECDSA_SHA512 OID_ANSI_X9_62_SIG_SHA2 "\x04" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/polarssl/pk.h b/include/polarssl/pk.h index 4e52a75d2..29aec309f 100644 --- a/include/polarssl/pk.h +++ b/include/polarssl/pk.h @@ -52,6 +52,9 @@ typedef enum { POLARSSL_PK_ECKEY, POLARSSL_PK_ECKEY_DH, #endif +#if defined(POLARSSL_ECDSA_C) + POLARSSL_PK_ECDSA, +#endif } pk_type_t; /** diff --git a/library/oid.c b/library/oid.c index 449b3e1f0..366720ec0 100644 --- a/library/oid.c +++ b/library/oid.c @@ -298,6 +298,26 @@ static const oid_sig_alg_t oid_sig_alg[] = { OID_RSA_SHA_OBS, "sha-1WithRSAEncryption", "RSA with SHA1" }, POLARSSL_MD_SHA1, POLARSSL_PK_RSA, }, + { + { OID_ECDSA_SHA1, "ecdsa-with-SHA1", "ECDSA with SHA1" }, + POLARSSL_MD_SHA1, POLARSSL_PK_ECDSA, + }, + { + { OID_ECDSA_SHA224, "ecdsa-with-SHA224", "ECDSA with SHA224" }, + POLARSSL_MD_SHA224, POLARSSL_PK_ECDSA, + }, + { + { OID_ECDSA_SHA256, "ecdsa-with-SHA256", "ECDSA with SHA256" }, + POLARSSL_MD_SHA256, POLARSSL_PK_ECDSA, + }, + { + { OID_ECDSA_SHA384, "ecdsa-with-SHA384", "ECDSA with SHA384" }, + POLARSSL_MD_SHA384, POLARSSL_PK_ECDSA, + }, + { + { OID_ECDSA_SHA512, "ecdsa-with-SHA512", "ECDSA with SHA512" }, + POLARSSL_MD_SHA512, POLARSSL_PK_ECDSA, + }, { { NULL, NULL, NULL }, 0, 0,