summaryrefslogtreecommitdiff
path: root/src/sbearssl
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbearssl')
-rw-r--r--src/sbearssl/sbearssl_cert_readbigpem.c7
-rw-r--r--src/sbearssl/sbearssl_cert_readfile.c11
-rw-r--r--src/sbearssl/sbearssl_ec_issuer_keytype.c1
-rw-r--r--src/sbearssl/sbearssl_pem_decode_from_buffer.c13
-rw-r--r--src/sbearssl/sbearssl_s6tlsc.c1
-rw-r--r--src/sbearssl/sbearssl_s6tlsd.c2
-rw-r--r--src/sbearssl/sbearssl_setclientcert.c1
-rw-r--r--src/sbearssl/sbearssl_skey_readfile.c9
-rw-r--r--src/sbearssl/sbearssl_ta_readdir.c11
-rw-r--r--src/sbearssl/sbearssl_x500_from_ta.c6
-rw-r--r--src/sbearssl/sbearssl_x509_minimal_set_tai.c2
11 files changed, 28 insertions, 36 deletions
diff --git a/src/sbearssl/sbearssl_cert_readbigpem.c b/src/sbearssl/sbearssl_cert_readbigpem.c
index d09c997..9df5ebd 100644
--- a/src/sbearssl/sbearssl_cert_readbigpem.c
+++ b/src/sbearssl/sbearssl_cert_readbigpem.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <bearssl.h>
-#include <skalibs/bytestr.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
@@ -33,8 +32,8 @@ int sbearssl_cert_readbigpem (char const *fn, genalloc *certs, stralloc *sa)
for (; i < n ; i++)
{
char const *name = sa->s + p[i].name ;
- if (!str_diff(name, "CERTIFICATE")
- || !str_diff(name, "X509 CERTIFICATE"))
+ if (!strcmp(name, "CERTIFICATE")
+ || !strcmp(name, "X509 CERTIFICATE"))
{
sbearssl_cert sc = { .data = p[i].data, .datalen = p[i].datalen } ;
if (!genalloc_append(sbearssl_cert, certs, &sc)) goto fail ;
diff --git a/src/sbearssl/sbearssl_cert_readfile.c b/src/sbearssl/sbearssl_cert_readfile.c
index f63fde4..746c2e8 100644
--- a/src/sbearssl/sbearssl_cert_readfile.c
+++ b/src/sbearssl/sbearssl_cert_readfile.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <bearssl.h>
-#include <skalibs/bytestr.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
@@ -19,7 +18,7 @@ int sbearssl_cert_readfile (char const *fn, genalloc *certs, stralloc *sa)
int certswasnull = !genalloc_s(sbearssl_cert, certs) ;
int sawasnull = !sa->s ;
{
- register ssize_t r = openreadnclose(fn, buf, SBEARSSL_MAXCERTFILESIZE) ;
+ ssize_t r = openreadnclose(fn, buf, SBEARSSL_MAXCERTFILESIZE) ;
if (r < 0) return r ;
n = r ;
}
@@ -34,15 +33,15 @@ int sbearssl_cert_readfile (char const *fn, genalloc *certs, stralloc *sa)
genalloc pems = GENALLOC_ZERO ;
size_t i = 0 ;
sbearssl_pemobject *p ;
- register int r = sbearssl_pem_decode_from_string(buf, n, &pems, sa) ;
+ int r = sbearssl_pem_decode_from_string(buf, n, &pems, sa) ;
if (r) return r ;
p = genalloc_s(sbearssl_pemobject, &pems) ;
n = genalloc_len(sbearssl_pemobject, &pems) ;
for (; i < n ; i++)
{
char const *name = sa->s + p[i].name ;
- if (!str_diff(name, "CERTIFICATE")
- || !str_diff(name, "X509 CERTIFICATE"))
+ if (!strcmp(name, "CERTIFICATE")
+ || !strcmp(name, "X509 CERTIFICATE"))
{
sbearssl_cert cert = { .data = p[i].data, .datalen = p[i].datalen } ;
if (!genalloc_append(sbearssl_cert, certs, &cert))
diff --git a/src/sbearssl/sbearssl_ec_issuer_keytype.c b/src/sbearssl/sbearssl_ec_issuer_keytype.c
index 2958e8d..c59da37 100644
--- a/src/sbearssl/sbearssl_ec_issuer_keytype.c
+++ b/src/sbearssl/sbearssl_ec_issuer_keytype.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <errno.h>
#include <bearssl.h>
#include <skalibs/stralloc.h>
diff --git a/src/sbearssl/sbearssl_pem_decode_from_buffer.c b/src/sbearssl/sbearssl_pem_decode_from_buffer.c
index e246b87..cacabd9 100644
--- a/src/sbearssl/sbearssl_pem_decode_from_buffer.c
+++ b/src/sbearssl/sbearssl_pem_decode_from_buffer.c
@@ -1,10 +1,9 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/uio.h>
#include <errno.h>
#include <bearssl.h>
#include <skalibs/error.h>
-#include <skalibs/siovec.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
@@ -26,19 +25,19 @@ int sbearssl_pem_decode_from_buffer (buffer *b, genalloc *list, stralloc *sa)
br_pem_decoder_init(&ctx) ;
for (;;)
{
- siovec_t v[2] ;
+ struct iovec v[2] ;
ssize_t rr = buffer_fill(b) ;
if (rr < 0) goto rfail ;
if (!rr) break ;
buffer_rpeek(b, v) ;
- r = sbearssl_pem_push(&ctx, v[0].s, v[0].len, &po, list, &blah, &inobj) ;
+ r = sbearssl_pem_push(&ctx, v[0].iov_base, v[0].iov_len, &po, list, &blah, &inobj) ;
if (r) goto fail ;
- if (v[1].len)
+ if (v[1].iov_len)
{
- r = sbearssl_pem_push(&ctx, v[1].s, v[1].len, &po, list, &blah, &inobj) ;
+ r = sbearssl_pem_push(&ctx, v[1].iov_base, v[1].iov_len, &po, list, &blah, &inobj) ;
if (r) goto fail ;
}
- buffer_rseek(b, v[0].len + v[1].len) ;
+ buffer_rseek(b, v[0].iov_len + v[1].iov_len) ;
}
if (!inobj) return 0 ;
diff --git a/src/sbearssl/sbearssl_s6tlsc.c b/src/sbearssl/sbearssl_s6tlsc.c
index c6ca4c1..057929f 100644
--- a/src/sbearssl/sbearssl_s6tlsc.c
+++ b/src/sbearssl/sbearssl_s6tlsc.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
diff --git a/src/sbearssl/sbearssl_s6tlsd.c b/src/sbearssl/sbearssl_s6tlsd.c
index 816d746..e91ef54 100644
--- a/src/sbearssl/sbearssl_s6tlsd.c
+++ b/src/sbearssl/sbearssl_s6tlsd.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <bearssl.h>
diff --git a/src/sbearssl/sbearssl_setclientcert.c b/src/sbearssl/sbearssl_setclientcert.c
index 07b1385..74bfd20 100644
--- a/src/sbearssl/sbearssl_setclientcert.c
+++ b/src/sbearssl/sbearssl_setclientcert.c
@@ -24,6 +24,5 @@ int sbearssl_setclientcert (br_ssl_client_context *cc, br_x509_certificate const
strerr_dief1x(96, "unsupported private key type") ;
}
-
return 0 ;
}
diff --git a/src/sbearssl/sbearssl_skey_readfile.c b/src/sbearssl/sbearssl_skey_readfile.c
index c406de0..7e7df51 100644
--- a/src/sbearssl/sbearssl_skey_readfile.c
+++ b/src/sbearssl/sbearssl_skey_readfile.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <bearssl.h>
-#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/djbunix.h>
@@ -49,9 +48,9 @@ int sbearssl_skey_readfile (char const *fn, sbearssl_skey *key, stralloc *sa)
for (; i < n ; i++)
{
char const *name = tmp.s + p[i].name ;
- if (!str_diff(name, "RSA PRIVATE KEY")
- || !str_diff(name, "EC PRIVATE KEY")
- || !str_diff(name, "PRIVATE KEY"))
+ if (!strcmp(name, "RSA PRIVATE KEY")
+ || !strcmp(name, "EC PRIVATE KEY")
+ || !strcmp(name, "PRIVATE KEY"))
{
r = decode_key(key, tmp.s + p[i].data, p[i].datalen, sa) ;
if (r) goto fail ;
diff --git a/src/sbearssl/sbearssl_ta_readdir.c b/src/sbearssl/sbearssl_ta_readdir.c
index de39eca..829d7a6 100644
--- a/src/sbearssl/sbearssl_ta_readdir.c
+++ b/src/sbearssl/sbearssl_ta_readdir.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/direntry.h>
@@ -13,7 +12,7 @@ int sbearssl_ta_readdir (char const *dirfn, genalloc *taga, stralloc *tasa)
{
size_t tasabase = tasa->len ;
size_t tagabase = genalloc_len(sbearssl_ta, taga) ;
- size_t dirfnlen = str_len(dirfn) ;
+ size_t dirfnlen = strlen(dirfn) ;
int tasawasnull = !tasa->s ;
int tagawasnull = !genalloc_s(sbearssl_ta, taga) ;
stralloc certsa = STRALLOC_ZERO ;
@@ -29,11 +28,11 @@ int sbearssl_ta_readdir (char const *dirfn, genalloc *taga, stralloc *tasa)
if (!d) break ;
if (d->d_name[0] == '.') continue ;
{
- size_t dlen = str_len(d->d_name) ;
+ size_t dlen = strlen(d->d_name) ;
char fn[dirfnlen + dlen + 2] ;
- byte_copy(fn, dirfnlen, dirfn) ;
+ memcpy(fn, dirfn, dirfnlen) ;
fn[dirfnlen] = '/' ;
- byte_copy(fn + dirfnlen + 1, dlen, d->d_name) ;
+ memcpy(fn + dirfnlen + 1, d->d_name, dlen) ;
fn[dirfnlen + 1 + dlen] = 0 ;
genalloc_setlen(sbearssl_cert, &certga, 0) ;
certsa.len = 0 ;
diff --git a/src/sbearssl/sbearssl_x500_from_ta.c b/src/sbearssl/sbearssl_x500_from_ta.c
index 50a132b..d655919 100644
--- a/src/sbearssl/sbearssl_x500_from_ta.c
+++ b/src/sbearssl/sbearssl_x500_from_ta.c
@@ -1,15 +1,15 @@
/* ISC license. */
+#include <string.h>
#include <bearssl.h>
-#include <skalibs/bytestr.h>
#include <s6-networking/sbearssl.h>
void sbearssl_x500_from_ta (br_x500_name *names, sbearssl_ta const *sta, size_t n, char *storage, char const *tastorage)
{
while (n--)
{
- register size_t len = sta->dnlen ;
- byte_copy(storage, len, tastorage + sta->dn) ;
+ size_t len = sta->dnlen ;
+ memcpy(storage, tastorage + sta->dn, len) ;
sta++ ;
names->data = (unsigned char *)storage ;
names->len = len ;
diff --git a/src/sbearssl/sbearssl_x509_minimal_set_tai.c b/src/sbearssl/sbearssl_x509_minimal_set_tai.c
index 11b1ad6..cfa12be 100644
--- a/src/sbearssl/sbearssl_x509_minimal_set_tai.c
+++ b/src/sbearssl/sbearssl_x509_minimal_set_tai.c
@@ -9,7 +9,7 @@
int sbearssl_x509_minimal_set_tai (br_x509_minimal_context *ctx, tai_t const *t)
{
- uint64 u ;
+ uint64_t u ;
if (!utc_from_tai(&u, t)) return 0 ;
u -= TAI_MAGIC ;
br_x509_minimal_set_time(ctx, (uint32_t)(u / 86400 + 719528), u % 86400) ;