iPXE
cms.h
Go to the documentation of this file.
00001 #ifndef _IPXE_CMS_H
00002 #define _IPXE_CMS_H
00003 
00004 /** @file
00005  *
00006  * Cryptographic Message Syntax (PKCS #7)
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <time.h>
00013 #include <ipxe/asn1.h>
00014 #include <ipxe/crypto.h>
00015 #include <ipxe/x509.h>
00016 #include <ipxe/refcnt.h>
00017 #include <ipxe/uaccess.h>
00018 
00019 /** CMS signer information */
00020 struct cms_signer_info {
00021         /** List of signer information blocks */
00022         struct list_head list;
00023 
00024         /** Certificate chain */
00025         struct x509_chain *chain;
00026 
00027         /** Digest algorithm */
00028         struct digest_algorithm *digest;
00029         /** Public-key algorithm */
00030         struct pubkey_algorithm *pubkey;
00031 
00032         /** Signature */
00033         void *signature;
00034         /** Length of signature */
00035         size_t signature_len;
00036 };
00037 
00038 /** A CMS signature */
00039 struct cms_signature {
00040         /** Reference count */
00041         struct refcnt refcnt;
00042         /** List of all certificates */
00043         struct x509_chain *certificates;
00044         /** List of signer information blocks */
00045         struct list_head info;
00046 };
00047 
00048 /**
00049  * Get reference to CMS signature
00050  *
00051  * @v sig               CMS signature
00052  * @ret sig             CMS signature
00053  */
00054 static inline __attribute__ (( always_inline )) struct cms_signature *
00055 cms_get ( struct cms_signature *sig ) {
00056         ref_get ( &sig->refcnt );
00057         return sig;
00058 }
00059 
00060 /**
00061  * Drop reference to CMS signature
00062  *
00063  * @v sig               CMS signature
00064  */
00065 static inline __attribute__ (( always_inline )) void
00066 cms_put ( struct cms_signature *sig ) {
00067         ref_put ( &sig->refcnt );
00068 }
00069 
00070 extern int cms_signature ( const void *data, size_t len,
00071                            struct cms_signature **sig );
00072 extern int cms_verify ( struct cms_signature *sig, userptr_t data, size_t len,
00073                         const char *name, time_t time, struct x509_chain *store,
00074                         struct x509_root *root );
00075 
00076 #endif /* _IPXE_CMS_H */