-/* $OpenBSD: ct_b64.c,v 1.5 2021/12/18 16:34:52 tb Exp $ */
+/* $OpenBSD: ct_b64.c,v 1.6 2021/12/20 17:19:19 jsing Exp $ */
/*
* Written by Rob Stradling (rob@comodo.com) and Stephen Henson
* (steve@openssl.org) for the OpenSSL project 2014.
#include <openssl/err.h>
#include <openssl/evp.h>
+#include "bytestring.h"
#include "ct_local.h"
/*
ct_log_entry_type_t entry_type, uint64_t timestamp,
const char *extensions_base64, const char *signature_base64)
{
- SCT *sct = SCT_new();
unsigned char *dec = NULL;
- const unsigned char* p = NULL;
int declen;
+ SCT *sct;
+ CBS cbs;
- if (sct == NULL) {
+ if ((sct = SCT_new()) == NULL) {
CTerror(ERR_R_MALLOC_FAILURE);
return NULL;
}
goto err;
}
- p = dec;
- if (o2i_SCT_signature(sct, &p, declen) <= 0)
+ CBS_init(&cbs, dec, declen);
+ if (!o2i_SCT_signature(sct, &cbs))
goto err;
free(dec);
dec = NULL;
-/* $OpenBSD: ct_local.h,v 1.7 2021/12/18 17:26:54 tb Exp $ */
+/* $OpenBSD: ct_local.h,v 1.8 2021/12/20 17:19:19 jsing Exp $ */
/*
* Written by Rob Percival (robpercival@google.com) for the OpenSSL project.
*/
#include <openssl/ct.h>
#include <openssl/evp.h>
+#include <openssl/safestack.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
-#include <openssl/safestack.h>
+
+#include "bytestring.h"
/* Number of bytes in an SCT v1 LogID - see RFC 6962 section 3.2. */
#define CT_V1_LOG_ID_LEN 32
* If an error occurs, the SCT's signature NID may be updated whilst the
* signature field itself remains unset.
*/
-int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len);
+int o2i_SCT_signature(SCT *sct, CBS *cbs);
/*
* Handlers for Certificate Transparency X509v3/OCSP extensions
-/* $OpenBSD: ct_oct.c,v 1.6 2021/12/18 16:34:52 tb Exp $ */
+/* $OpenBSD: ct_oct.c,v 1.7 2021/12/20 17:19:19 jsing Exp $ */
/*
* Written by Rob Stradling (rob@comodo.com) and Stephen Henson
* (steve@openssl.org) for the OpenSSL project 2014.
#include "bytestring.h"
#include "ct_local.h"
-static int
-o2i_SCT_signature_internal(SCT *sct, CBS *cbs)
+int
+o2i_SCT_signature(SCT *sct, CBS *cbs)
{
uint8_t hash_alg, sig_alg;
CBS signature;
return 0;
}
-int
-o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len)
-{
- size_t sig_len;
- CBS cbs;
-
- CBS_init(&cbs, *in, len);
-
- if (!o2i_SCT_signature_internal(sct, &cbs))
- return -1;
-
- sig_len = len - CBS_len(&cbs);
- if (sig_len > INT_MAX)
- return -1;
-
- *in = CBS_data(&cbs);
-
- return sig_len;
-}
-
static int
o2i_SCT_internal(SCT **out_sct, CBS *cbs)
{
if (!CBS_stow(&extensions, &sct->ext, &sct->ext_len))
goto err;
- if (!o2i_SCT_signature_internal(sct, cbs))
+ if (!o2i_SCT_signature(sct, cbs))
goto err;
if (CBS_len(cbs) != 0)