~ubuntu-branches/ubuntu/raring/ipxe/raring

« back to all changes in this revision

Viewing changes to src/include/ipxe/ocsp.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-11-14 15:47:31 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20121114154731-jhuy5d1h2jw75qe9
Tags: 1.0.0+git-4.d6b0b76-0ubuntu1
* New upstream snapshot:
  - d/p/iscsi*.patch: Dropped - included in snapshot.
  - Refreshed all other patches.
* d/p/enable-https.patch: Enable HTTPS support (LP: #1025239).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _IPXE_OCSP_H
 
2
#define _IPXE_OCSP_H
 
3
 
 
4
/** @file
 
5
 *
 
6
 * Online Certificate Status Protocol
 
7
 *
 
8
 */
 
9
 
 
10
FILE_LICENCE ( GPL2_OR_LATER );
 
11
 
 
12
#include <stdarg.h>
 
13
#include <time.h>
 
14
#include <ipxe/asn1.h>
 
15
#include <ipxe/x509.h>
 
16
#include <ipxe/refcnt.h>
 
17
 
 
18
/** OCSP algorithm identifier */
 
19
#define OCSP_ALGORITHM_IDENTIFIER( ... )                                \
 
20
        ASN1_OID, VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__,            \
 
21
        ASN1_NULL, 0x00
 
22
 
 
23
/* OCSP response statuses */
 
24
#define OCSP_STATUS_SUCCESSFUL          0x00
 
25
#define OCSP_STATUS_MALFORMED_REQUEST   0x01
 
26
#define OCSP_STATUS_INTERNAL_ERROR      0x02
 
27
#define OCSP_STATUS_TRY_LATER           0x03
 
28
#define OCSP_STATUS_SIG_REQUIRED        0x05
 
29
#define OCSP_STATUS_UNAUTHORIZED        0x06
 
30
 
 
31
/** An OCSP request */
 
32
struct ocsp_request {
 
33
        /** Request builder */
 
34
        struct asn1_builder builder;
 
35
        /** Certificate ID */
 
36
        struct asn1_cursor cert_id;
 
37
};
 
38
 
 
39
/** An OCSP response */
 
40
struct ocsp_response {
 
41
        /** Raw response */
 
42
        void *data;
 
43
        /** Raw tbsResponseData */
 
44
        struct asn1_cursor tbs;
 
45
        /** Time at which status is known to be correct */
 
46
        time_t this_update;
 
47
        /** Time at which newer status information will be available */
 
48
        time_t next_update;
 
49
        /** Signature algorithm */
 
50
        struct asn1_algorithm *algorithm;
 
51
        /** Signature value */
 
52
        struct asn1_bit_string signature;
 
53
        /** Signing certificate */
 
54
        struct x509_certificate *signer;
 
55
};
 
56
 
 
57
/** An OCSP check */
 
58
struct ocsp_check {
 
59
        /** Reference count */
 
60
        struct refcnt refcnt;
 
61
        /** Certificate being checked */
 
62
        struct x509_certificate *cert;
 
63
        /** Issuing certificate */
 
64
        struct x509_certificate *issuer;
 
65
        /** URI string */
 
66
        char *uri_string;
 
67
        /** Request */
 
68
        struct ocsp_request request;
 
69
        /** Response */
 
70
        struct ocsp_response response;
 
71
};
 
72
 
 
73
/**
 
74
 * Get reference to OCSP check
 
75
 *
 
76
 * @v ocsp              OCSP check
 
77
 * @ret ocsp            OCSP check
 
78
 */
 
79
static inline __attribute__ (( always_inline )) struct ocsp_check *
 
80
ocsp_get ( struct ocsp_check *ocsp ) {
 
81
        ref_get ( &ocsp->refcnt );
 
82
        return ocsp;
 
83
}
 
84
 
 
85
/**
 
86
 * Drop reference to OCSP check
 
87
 *
 
88
 * @v ocsp              OCSP check
 
89
 */
 
90
static inline __attribute__ (( always_inline )) void
 
91
ocsp_put ( struct ocsp_check *ocsp ) {
 
92
        ref_put ( &ocsp->refcnt );
 
93
}
 
94
 
 
95
extern int ocsp_check ( struct x509_certificate *cert,
 
96
                        struct x509_certificate *issuer,
 
97
                        struct ocsp_check **ocsp );
 
98
extern int ocsp_response ( struct ocsp_check *ocsp, const void *data,
 
99
                           size_t len );
 
100
extern int ocsp_validate ( struct ocsp_check *check, time_t time );
 
101
 
 
102
#endif /* _IPXE_OCSP_H */