123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- #include <stddef.h>
- #include <openssl/ct.h>
- #include <openssl/evp.h>
- #include <openssl/x509.h>
- #include <openssl/x509v3.h>
- #include <openssl/safestack.h>
- # define MAX_SCT_SIZE 65535
- # define MAX_SCT_LIST_SIZE MAX_SCT_SIZE
- #define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \
- (((unsigned int)((c)[1])) )),c+=2)
- #define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \
- c[1]=(unsigned char)(((s) )&0xff)),c+=2)
- #define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \
- c[1]=(unsigned char)(((l)>> 8)&0xff), \
- c[2]=(unsigned char)(((l) )&0xff)),c+=3)
- #define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \
- l|=((uint64_t)(*((c)++)))<<48, \
- l|=((uint64_t)(*((c)++)))<<40, \
- l|=((uint64_t)(*((c)++)))<<32, \
- l|=((uint64_t)(*((c)++)))<<24, \
- l|=((uint64_t)(*((c)++)))<<16, \
- l|=((uint64_t)(*((c)++)))<< 8, \
- l|=((uint64_t)(*((c)++))))
- #define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \
- *((c)++)=(unsigned char)(((l)>>48)&0xff), \
- *((c)++)=(unsigned char)(((l)>>40)&0xff), \
- *((c)++)=(unsigned char)(((l)>>32)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
- struct sct_st {
- sct_version_t version;
-
- unsigned char *sct;
- size_t sct_len;
-
- unsigned char *log_id;
- size_t log_id_len;
-
- uint64_t timestamp;
- unsigned char *ext;
- size_t ext_len;
- unsigned char hash_alg;
- unsigned char sig_alg;
- unsigned char *sig;
- size_t sig_len;
-
- ct_log_entry_type_t entry_type;
-
- sct_source_t source;
-
- sct_validation_status_t validation_status;
- };
- struct sct_ctx_st {
-
- EVP_PKEY *pkey;
-
- unsigned char *pkeyhash;
- size_t pkeyhashlen;
-
- unsigned char *ihash;
- size_t ihashlen;
-
- unsigned char *certder;
- size_t certderlen;
-
- unsigned char *preder;
- size_t prederlen;
-
- uint64_t epoch_time_in_ms;
- };
- struct ct_policy_eval_ctx_st {
- X509 *cert;
- X509 *issuer;
- CTLOG_STORE *log_store;
-
- uint64_t epoch_time_in_ms;
- };
- SCT_CTX *SCT_CTX_new(void);
- void SCT_CTX_free(SCT_CTX *sctx);
- __owur int SCT_CTX_set1_cert(SCT_CTX *sctx, X509 *cert, X509 *presigner);
- __owur int SCT_CTX_set1_issuer(SCT_CTX *sctx, const X509 *issuer);
- __owur int SCT_CTX_set1_issuer_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey);
- __owur int SCT_CTX_set1_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey);
- void SCT_CTX_set_time(SCT_CTX *sctx, uint64_t time_in_ms);
- __owur int SCT_CTX_verify(const SCT_CTX *sctx, const SCT *sct);
- __owur int SCT_is_complete(const SCT *sct);
- __owur int SCT_signature_is_complete(const SCT *sct);
- __owur int i2o_SCT_signature(const SCT *sct, unsigned char **out);
- __owur int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len);
- extern const X509V3_EXT_METHOD v3_ct_scts[3];
|