completed pkcs7 parsing methods

This commit is contained in:
Andreas Steffen
2007-10-07 22:11:42 +00:00
parent 2d8a418059
commit 06ba2d36c3
2 changed files with 292 additions and 474 deletions
+55 -17
View File
@@ -27,7 +27,7 @@
#ifndef _PKCS7_H
#define _PKCS7_H
typedef struct pkcs7_contentInfo_t pkcs7_contentInfo_t;
typedef struct pkcs7_t pkcs7_t;
#include <library.h>
#include <crypto/x509.h>
@@ -44,37 +44,75 @@ typedef struct pkcs7_contentInfo_t pkcs7_contentInfo_t;
*
* @ingroup crypto
*/
struct pkcs7_contentInfo_t {
struct pkcs7_t {
/**
* @brief Is contentInfo object of type signedData?.
* @brief Check if the PKCS#7 contentType is data
*
* @param this calling object
* @return TRUE if of type signedData
* @return TRUE if the contentType is data
*/
bool (*is_signedData) (pkcs7_contentInfo_t *this);
bool (*is_data) (pkcs7_t *this);
/**
* @brief Is contentInfo object of type envelopedData?.
* @brief Check if the PKCS#7 contentType is signedData
*
* @param this calling object
* @return TRUE if of type envelopedData
* @return TRUE if the contentType is signedData
*/
bool (*is_envelopedData) (pkcs7_contentInfo_t *this);
bool (*is_signedData) (pkcs7_t *this);
/**
* @brief Check if the PKCS#7 contentType is envelopedData
*
* @param this calling object
* @return TRUE if the contentType is envelopedData
*/
bool (*is_envelopedData) (pkcs7_t *this);
/**
* @brief Parse a PKCS#7 data content.
*
* @param this calling object
* @return TRUE if parsing was successful
*/
bool (*parse_data) (pkcs7_t *this);
/**
* @brief Parse a PKCS#7 signedData content.
*
* @param this calling object
* @param cacert cacert used to verify the signature
* @return TRUE if parsing was successful
*/
bool (*parse_signedData) (pkcs7_t *this, x509_t *cacert);
/**
* @brief Parse a PKCS#7 envelopedData content.
*
* @param this calling object
* @param serialNumber serialNumber of the request
* @param key RSA private key used to decrypt the symmetric key
* @return TRUE if parsing was successful
*/
bool (*parse_envelopedData) (pkcs7_t *this, chunk_t serialNumber, rsa_private_key_t *key);
/**
* @brief Destroys the contentInfo object.
*
* @param this contentInfo object to destroy
* @param this PKCS#7 contentInfo object to destroy
*/
void (*destroy) (pkcs7_contentInfo_t *this);
void (*destroy) (pkcs7_t *this);
};
extern chunk_t pkcs7_contentType_attribute(void);
extern chunk_t pkcs7_messageDigest_attribute(chunk_t content, int digest_alg);
extern chunk_t pkcs7_build_issuerAndSerialNumber(const x509_t *cert);
extern chunk_t pkcs7_build_signedData(chunk_t data, chunk_t attributes
,const x509_t *cert, int digest_alg, const rsa_private_key_t *key);
extern chunk_t pkcs7_build_envelopedData(chunk_t data, const x509_t *cert
, int cipher);
/**
* @brief Read a PKCS#7 contentInfo object from a DER encoded chunk.
*
* @param chunk chunk containing DER encoded data
* @param level ASN.1 parsing start level
* @return created pkcs7_contentInfo object, or NULL if invalid.
*
* @ingroup crypto
*/
pkcs7_t *pkcs7_create_from_chunk(chunk_t chunk, u_int level);
#endif /* _PKCS7_H */