iPXE
cms.h
Go to the documentation of this file.
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_OR_UBDL );
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 */
21  /** List of signer information blocks */
22  struct list_head list;
23 
24  /** Certificate chain */
25  struct x509_chain *chain;
26 
27  /** Digest algorithm */
29  /** Public-key algorithm */
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 */
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 */
#define __attribute__(x)
Definition: compiler.h:10
struct list_head info
List of signer information blocks.
Definition: cms.h:45
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const char * name
Definition: ath9k_hw.c:1984
size_t signature_len
Length of signature.
Definition: cms.h:35
u8 sig
Definition: CIB_PRM.h:43
struct stp_switch root
Root switch.
Definition: stp.h:26
struct pubkey_algorithm * pubkey
Public-key algorithm.
Definition: cms.h:30
struct x509_chain * chain
Certificate chain.
Definition: cms.h:25
static void cms_put(struct cms_signature *sig)
Drop reference to CMS signature.
Definition: cms.h:66
int cms_verify(struct cms_signature *sig, userptr_t data, size_t len, const char *name, time_t time, struct x509_chain *store, struct x509_root *root)
Verify CMS signature.
Definition: cms.c:681
Cryptographic API.
Access to external ("user") memory.
A doubly-linked list entry (or list head)
Definition: list.h:18
A reference counter.
Definition: refcnt.h:26
An X.509 certificate chain.
Definition: x509.h:177
ASN.1 encoding.
CMS signer information.
Definition: cms.h:20
void * signature
Signature.
Definition: cms.h:33
int cms_signature(const void *data, size_t len, struct cms_signature **sig)
Create CMS signature.
Definition: cms.c:492
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
X.509 certificates.
struct list_head list
List of signer information blocks.
Definition: cms.h:22
An X.509 root certificate store.
Definition: x509.h:344
uint32_t len
Length.
Definition: ena.h:14
struct digest_algorithm * digest
Digest algorithm.
Definition: cms.h:28
A message digest algorithm.
Definition: crypto.h:16
Reference counting.
A CMS signature.
Definition: cms.h:39
struct x509_chain * certificates
List of all certificates.
Definition: cms.h:43
static struct cms_signature * cms_get(struct cms_signature *sig)
Get reference to CMS signature.
Definition: cms.h:55
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int64_t time_t
Seconds since the Epoch.
Definition: time.h:18
Time source.
uint64_t time
Current time.
Definition: ntlm.h:20
A public key algorithm.
Definition: crypto.h:94
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33