From 47fce02bd80cfddb5af7b3ed4044c295b8434aec Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Fri, 28 Jun 2013 17:34:34 +0200
Subject: [PATCH] Defines around module-dependent OIDs
---
include/polarssl/oid.h | 18 ++++++++++++++++--
library/oid.c | 8 ++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/include/polarssl/oid.h b/include/polarssl/oid.h
index 27a3cceec..e63c169a6 100644
--- a/include/polarssl/oid.h
+++ b/include/polarssl/oid.h
@@ -28,11 +28,21 @@
#define POLARSSL_OID_H
#include
+#include "config.h"
#include "asn1.h"
-#include "cipher.h"
-#include "md.h"
#include "pk.h"
+
+#if defined(POLARSSL_CIPHER_C)
+#include "cipher.h"
+#endif
+
+#if defined(POLARSSL_MD_C)
+#include "md.h"
+#endif
+
+#if defined(POLARSSL_X509_PARSE_C)
#include "x509.h"
+#endif
#define POLARSSL_ERR_OID_NOT_FOUND -0x002E /**< OID is not found. */
@@ -283,6 +293,7 @@ int oid_get_attr_short_name( const asn1_buf *oid, const char **short_name );
*/
int oid_get_pk_alg( const asn1_buf *oid, pk_type_t *pk_alg );
+#if defined(POLARSSL_MD_C)
/**
* \brief Translate SignatureAlgorithm OID into md_type and pk_type
*
@@ -326,6 +337,7 @@ int oid_get_oid_by_sig_alg( pk_type_t pk_alg, md_type_t md_alg,
* \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND
*/
int oid_get_md_alg( const asn1_buf *oid, md_type_t *md_alg );
+#endif /* POLARSSL_MD_C */
/**
* \brief Translate Extended Key Usage OID into description
@@ -347,6 +359,7 @@ int oid_get_extended_key_usage( const asn1_buf *oid, const char **desc );
*/
int oid_get_oid_by_md( md_type_t md_alg, const char **oid_str );
+#if defined(POLARSSL_CIPHER_C)
/**
* \brief Translate encryption algorithm OID into cipher_type
*
@@ -356,6 +369,7 @@ int oid_get_oid_by_md( md_type_t md_alg, const char **oid_str );
* \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND
*/
int oid_get_cipher_alg( const asn1_buf *oid, cipher_type_t *cipher_alg );
+#endif /* POLARSSL_CIPHER_C */
#if defined(POLARSSL_PKCS12_C)
/**
diff --git a/library/oid.c b/library/oid.c
index 7c1790159..c4edcc58b 100644
--- a/library/oid.c
+++ b/library/oid.c
@@ -214,6 +214,7 @@ FN_OID_GET_ATTR1(oid_get_extended_key_usage, oid_descriptor_t, ext_key_usage, co
#endif /* POLARSSL_X509_PARSE_C || POLARSSL_X509_WRITE_C */
+#if defined(POLARSSL_MD_C)
/*
* For SignatureAlgorithmIdentifier
*/
@@ -290,6 +291,7 @@ int oid_get_oid_by_sig_alg( pk_type_t pk_alg, md_type_t md_alg,
return( POLARSSL_ERR_OID_NOT_FOUND );
}
+#endif /* POLARSSL_MD_C */
/*
* For PublicKeyInfo
@@ -314,6 +316,7 @@ static const oid_pk_alg_t oid_pk_alg[] =
FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg);
FN_OID_GET_ATTR1(oid_get_pk_alg, oid_pk_alg_t, pk_alg, pk_type_t, pk_alg);
+#if defined(POLARSSL_CIPHER_C)
/*
* For PKCS#5 PBES2 encryption algorithm
*/
@@ -340,7 +343,9 @@ static const oid_cipher_alg_t oid_cipher_alg[] =
FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg);
FN_OID_GET_ATTR1(oid_get_cipher_alg, oid_cipher_alg_t, cipher_alg, cipher_type_t, cipher_alg);
+#endif /* POLARSSL_CIPHER_C */
+#if defined(POLARSSL_MD_C)
/*
* For digestAlgorithm
*/
@@ -413,7 +418,9 @@ int oid_get_oid_by_md( md_type_t md_alg, const char **oid_str )
return( POLARSSL_ERR_OID_NOT_FOUND );
}
+#endif /* POLARSSL_MD_C */
+#if defined(POLARSSL_PKCS12_C)
/*
* For PKCS#12 PBEs
*/
@@ -441,6 +448,7 @@ static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] =
FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg);
FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, md_type_t, md_alg, cipher_type_t, cipher_alg);
+#endif /* POLARSSL_PKCS12_C */
#if defined _MSC_VER && !defined snprintf
#include