Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / cms.h
1 #ifndef _IPXE_CMS_H
2 #define _IPXE_CMS_H
3
4 /** @file
5  *
6  * Cryptographic Message Syntax (PKCS #7)
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <time.h>
13 #include <ipxe/asn1.h>
14 #include <ipxe/crypto.h>
15 #include <ipxe/x509.h>
16 #include <ipxe/refcnt.h>
17 #include <ipxe/uaccess.h>
18
19 /** CMS signer information */
20 struct cms_signer_info {
21         /** List of signer information blocks */
22         struct list_head list;
23
24         /** Certificate chain */
25         struct x509_chain *chain;
26
27         /** Digest algorithm */
28         struct digest_algorithm *digest;
29         /** Public-key algorithm */
30         struct pubkey_algorithm *pubkey;
31
32         /** Signature */
33         void *signature;
34         /** Length of signature */
35         size_t signature_len;
36 };
37
38 /** A CMS signature */
39 struct cms_signature {
40         /** Reference count */
41         struct refcnt refcnt;
42         /** List of all certificates */
43         struct x509_chain *certificates;
44         /** List of signer information blocks */
45         struct list_head info;
46 };
47
48 /**
49  * Get reference to CMS signature
50  *
51  * @v sig               CMS signature
52  * @ret sig             CMS signature
53  */
54 static inline __attribute__ (( always_inline )) struct cms_signature *
55 cms_get ( struct cms_signature *sig ) {
56         ref_get ( &sig->refcnt );
57         return sig;
58 }
59
60 /**
61  * Drop reference to CMS signature
62  *
63  * @v sig               CMS signature
64  */
65 static inline __attribute__ (( always_inline )) void
66 cms_put ( struct cms_signature *sig ) {
67         ref_put ( &sig->refcnt );
68 }
69
70 extern int cms_signature ( const void *data, size_t len,
71                            struct cms_signature **sig );
72 extern int cms_verify ( struct cms_signature *sig, userptr_t data, size_t len,
73                         const char *name, time_t time, struct x509_chain *store,
74                         struct x509_root *root );
75
76 #endif /* _IPXE_CMS_H */