Rizin
unix-like reverse engineering framework and cli tools
rz_x509.h
Go to the documentation of this file.
1 #ifndef RZ_X509_H
2 #define RZ_X509_H
3 
4 #include <rz_util/rz_asn1.h>
5 #include <rz_util/rz_pj.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 /*
12  * Following RFC 5280
13  */
14 
15 typedef struct rz_x509_validity_t {
19 
20 typedef struct rz_x509_name_t {
25 
27  RASN1String *algorithm; // OBJECT IDENTIFIER
28  RASN1String *parameters; // OPTIONAL
30 
31 /*
32 //SubjectKeyIdentifier OCTET STRING so it should be an ASN1Object
33 
34 typedef struct rz_x509_keyusage_t {
35  ut8 digitalSignature : 1;
36  ut8 contentCommitment : 1;
37  ut8 keyEncipherment : 1;
38  ut8 dataEncipherment : 1;
39  ut8 keyAgreement : 1;
40  ut8 keyCertSign : 1;
41  ut8 cRLSign : 1;
42  ut8 encipherOnly : 1;
43  ut8 decipherOnly : 1;
44 } X509KeyUsage;
45  */
46 
52 
55  // This is a bit string, but it encapsulate mod + pubkey
56  RASN1Binary *subjectPublicKey; // BIT STRING
57  // This struct won't follow RFC,
58  // just because it should be seen as this.
62 
63 typedef struct rz_x509_extension_t {
64  RASN1String *extnID; // OBJECT IDENTIFIER
65  bool critical;
66  RASN1Binary *extnValue; // OCTET STRING
68 
69 typedef struct rz_x509_extensions_t {
73 
74 typedef struct rz_x509_tbscertificate_t {
75  ut32 version; // INTEGER
82  RASN1Binary *issuerUniqueID; // BIT STRING
83  RASN1Binary *subjectUniqueID; // BIT STRING
86 
87 typedef struct rz_x509_certificate_t {
90  RASN1Binary *signature; // BIT STRING
92 
93 // RFC 1422
94 
95 typedef struct rz_x509_crlentry {
99 
103  RASN1String *lastUpdate; // UTCTime
104  RASN1String *nextUpdate; // UTCTime
108 
110 // RZ_API void rz_x509_free_crl(RX509CertificateRevocationList *crl);
111 // RZ_API void rz_x509_crl_dump(RX509CertificateRevocationList *crl, const char* pad);
114 
118 RZ_API void rz_x509_certificate_json(PJ *pj, RX509Certificate *certificate);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* RZ_X509_H */
static SblHeader sb
Definition: bin_mbn.c:26
#define RZ_API
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
uint32_t ut32
uint8_t ut8
Definition: lh5801.h:11
static void pad(RzStrBuf *sb, ut32 count)
Definition: protobuf.c:36
RZ_API void rz_x509_crl_json(PJ *pj, RX509CertificateRevocationList *crl)
Definition: x509.c:719
RZ_API RX509Certificate * rz_x509_parse_certificate2(const ut8 *buffer, ut32 length)
Definition: x509.c:249
struct rz_x509_extension_t RX509Extension
struct rz_x509_certificate_t RX509Certificate
RZ_API void rz_x509_free_certificate(RX509Certificate *certificate)
Definition: x509.c:387
RZ_API RX509CertificateRevocationList * rz_x509_parse_crl(RASN1Object *object)
Definition: x509.c:275
struct rz_x509_certificaterevocationlist RX509CertificateRevocationList
struct rz_x509_extensions_t RX509Extensions
struct rz_x509_subjectpublickeyinfo_t RX509SubjectPublicKeyInfo
struct rz_x509_crlentry RX509CRLEntry
RZ_API RX509Certificate * rz_x509_parse_certificate(RASN1Object *object)
Definition: x509.c:217
RZ_API void rz_x509_certificate_dump(RX509Certificate *cert, const char *pad, RzStrBuf *sb)
Definition: x509.c:546
struct rz_x509_validity_t RX509Validity
struct rz_x509_tbscertificate_t RX509TBSCertificate
RZ_API char * rz_x509_crl_to_string(RX509CertificateRevocationList *crl, const char *pad)
Definition: x509.c:592
struct rz_x509_algorithmidentifier_t RX509AlgorithmIdentifier
struct rz_x509_name_t RX509Name
RZ_API void rz_x509_certificate_json(PJ *pj, RX509Certificate *certificate)
Definition: x509.c:790
struct rz_x509_authoritykeyidentifier_t RX509AuthorityKeyIdentifier
Definition: buffer.h:15
Definition: rz_pj.h:12
RASN1String * algorithm
Definition: rz_x509.h:27
RASN1String * parameters
Definition: rz_x509.h:28
RASN1Binary * authorityCertSerialNumber
Definition: rz_x509.h:50
RX509TBSCertificate tbsCertificate
Definition: rz_x509.h:88
RASN1Binary * signature
Definition: rz_x509.h:90
RX509AlgorithmIdentifier algorithmIdentifier
Definition: rz_x509.h:89
RX509AlgorithmIdentifier signature
Definition: rz_x509.h:101
RX509CRLEntry ** revokedCertificates
Definition: rz_x509.h:106
RASN1Binary * userCertificate
Definition: rz_x509.h:96
RASN1String * revocationDate
Definition: rz_x509.h:97
RASN1Binary * extnValue
Definition: rz_x509.h:66
RASN1String * extnID
Definition: rz_x509.h:64
RX509Extension ** extensions
Definition: rz_x509.h:71
RASN1String ** names
Definition: rz_x509.h:23
RASN1String ** oids
Definition: rz_x509.h:22
ut32 length
Definition: rz_x509.h:21
RX509AlgorithmIdentifier algorithm
Definition: rz_x509.h:54
RASN1Binary * subjectPublicKeyExponent
Definition: rz_x509.h:59
RASN1Binary * subjectPublicKey
Definition: rz_x509.h:56
RASN1Binary * subjectPublicKeyModule
Definition: rz_x509.h:60
RX509SubjectPublicKeyInfo subjectPublicKeyInfo
Definition: rz_x509.h:81
RASN1String * serialNumber
Definition: rz_x509.h:76
RASN1Binary * subjectUniqueID
Definition: rz_x509.h:83
RX509AlgorithmIdentifier signature
Definition: rz_x509.h:77
RX509Validity validity
Definition: rz_x509.h:79
RASN1Binary * issuerUniqueID
Definition: rz_x509.h:82
RX509Extensions extensions
Definition: rz_x509.h:84
RASN1String * notBefore
Definition: rz_x509.h:16
RASN1String * notAfter
Definition: rz_x509.h:17