Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristaps committed Sep 2, 2016
1 parent 1957f24 commit 60b741f
Show file tree
Hide file tree
Showing 14 changed files with 350 additions and 351 deletions.
36 changes: 18 additions & 18 deletions acctproc.c
Expand Up @@ -50,23 +50,23 @@ bn2string(const BIGNUM *bn)
len = BN_num_bytes(bn);
if (NULL == (buf = malloc(len))) {
warn("malloc");
return(NULL);
return (NULL);
} else if (len != BN_bn2bin(bn, (unsigned char *)buf)) {
warnx("BN_bn2bin");
free(buf);
return(NULL);
return (NULL);
}

/* Convert to base64url. */

if (NULL == (bbuf = base64buf_url(buf, len))) {
warnx("base64buf_url");
free(buf);
return(NULL);
return (NULL);
}

free(buf);
return(bbuf);
return (bbuf);
}

/*
Expand All @@ -92,7 +92,7 @@ op_thumb_rsa(EVP_PKEY *pkey)

free(exp);
free(mod);
return(json);
return (json);
}

/*
Expand Down Expand Up @@ -161,7 +161,7 @@ op_thumbprint(int fd, EVP_PKEY *pkey)
free(thumb);
free(dig);
free(dig64);
return(rc);
return (rc);
}

static int
Expand All @@ -174,9 +174,9 @@ op_sign_rsa(char **head, char **prot, EVP_PKEY *pkey, const char *nonce)
*head = *prot = exp = mod = NULL;
rc = 0;

/*
* First, extract relevant portions of our private key.
* Then construct the public header.
/*
* First, extract relevant portions of our private key.
* Then construct the public header.
* Finally, format the header combined with the nonce.
*/

Expand All @@ -195,7 +195,7 @@ op_sign_rsa(char **head, char **prot, EVP_PKEY *pkey, const char *nonce)

free(exp);
free(mod);
return(rc);
return (rc);
}

/*
Expand All @@ -206,7 +206,7 @@ static int
op_sign(int fd, EVP_PKEY *pkey)
{
char *nonce, *pay,
*pay64, *prot, *prot64, *head,
*pay64, *prot, *prot64, *head,
*sign, *dig64, *fin;
int rc;
unsigned int digsz;
Expand All @@ -223,7 +223,7 @@ op_sign(int fd, EVP_PKEY *pkey)

if (NULL == (pay = readstr(fd, COMM_PAY)))
goto out;
else if (NULL == (nonce = readstr(fd, COMM_NONCE)))
else if (NULL == (nonce = readstr(fd, COMM_NONCE)))
goto out;

/* Base64-encode the payload. */
Expand Down Expand Up @@ -285,8 +285,8 @@ op_sign(int fd, EVP_PKEY *pkey)
goto out;
}

/*
* Write back in the correct JSON format.
/*
* Write back in the correct JSON format.
* If the reader is closed, just ignore it (we'll pick it up
* when we next enter the read loop).
*/
Expand All @@ -312,7 +312,7 @@ op_sign(int fd, EVP_PKEY *pkey)
free(dig);
free(dig64);
free(fin);
return(rc);
return (rc);
}

int
Expand All @@ -330,7 +330,7 @@ acctproc(int netsock, const char *acctkey, int newacct)
pkey = NULL;
rc = 0;

/*
/*
* First, open our private key file read-only or write-only if
* we're creating from scratch.
* Set our umask to be maximally restrictive.
Expand Down Expand Up @@ -359,7 +359,7 @@ acctproc(int netsock, const char *acctkey, int newacct)
else if ( ! sandbox_after(0))
goto out;

/*
/*
* Seed our PRNG with data from arc4random().
* Do this until we're told it's ok and use increments of 64
* bytes (arbitrarily).
Expand Down Expand Up @@ -434,6 +434,6 @@ acctproc(int netsock, const char *acctkey, int newacct)
EVP_PKEY_free(pkey);
ERR_print_errors_fp(stderr);
ERR_free_strings();
return(rc);
return (rc);
}

8 changes: 4 additions & 4 deletions base64.c
Expand Up @@ -35,11 +35,11 @@ static const char b64[] =
* Compute the maximum buffer required for a base64 encoded string of
* length "len".
*/
size_t
size_t
base64len(size_t len)
{

return(((len + 2) / 3 * 4) + 1);
return (((len + 2) / 3 * 4) + 1);
}

/*
Expand Down Expand Up @@ -114,7 +114,7 @@ base64buf_url(const char *data, size_t len)

sz = base64len(len);
if (NULL == (buf = malloc(sz)))
return(NULL);
return (NULL);

base64buf(buf, data, len);

Expand All @@ -126,5 +126,5 @@ base64buf_url(const char *data, size_t len)
else if ('=' == buf[i])
buf[i] = '\0';

return(buf);
return (buf);
}
30 changes: 15 additions & 15 deletions certproc.c
Expand Up @@ -49,34 +49,34 @@ x509buf(X509 *x, size_t *sz)

if (NULL == (bio = BIO_new(BIO_s_mem()))) {
warnx("BIO_new");
return(NULL);
return (NULL);
} else if ( ! PEM_write_bio_X509(bio, x)) {
warnx("PEM_write_bio_X509");
BIO_free(bio);
return(NULL);
return (NULL);
}

/*
* Now convert bio to string.
/*
* Now convert bio to string.
* Make into nil-terminated, just in case.
*/

if (NULL == (p = calloc(1, bio->num_write + 1))) {
warn("calloc");
BIO_free(bio);
return(NULL);
}
return (NULL);
}

ssz = BIO_read(bio, p, bio->num_write);
if (ssz < 0 || (unsigned)ssz != bio->num_write) {
warnx("BIO_read");
BIO_free(bio);
return(NULL);
return (NULL);
}

*sz = ssz;
BIO_free(bio);
return(p);
return (p);
}

int
Expand Down Expand Up @@ -132,8 +132,8 @@ certproc(int netsock, int filesock)
goto out;
}

/*
* Pass revocation right through to fileproc.
/*
* Pass revocation right through to fileproc.
* If the reader is terminated, ignore it.
*/

Expand Down Expand Up @@ -210,7 +210,7 @@ certproc(int netsock, int filesock)
if (chainsz <= strlen(MARKER) ||
strncmp(chain, MARKER, strlen(MARKER))) {
chaincp = (u_char *)chain;
chainx = d2i_X509(NULL,
chainx = d2i_X509(NULL,
(const u_char **)&chaincp, chainsz);
if (NULL == chainx) {
warnx("d2i_X509");
Expand All @@ -219,7 +219,7 @@ certproc(int netsock, int filesock)
free(chain);
if (NULL == (chain = x509buf(chainx, &chainsz)))
goto out;
}
}

/* Allow reader termination to just push us out. */

Expand All @@ -232,8 +232,8 @@ certproc(int netsock, int filesock)
if (cc <= 0)
goto out;

/*
* Next, convert the X509 to a buffer and send that.
/*
* Next, convert the X509 to a buffer and send that.
* Reader failure doesn't change anything.
*/

Expand All @@ -256,6 +256,6 @@ certproc(int netsock, int filesock)
free(chain);
ERR_print_errors_fp(stderr);
ERR_free_strings();
return(rc);
return (rc);
}

4 changes: 2 additions & 2 deletions chngproc.c
Expand Up @@ -63,7 +63,7 @@ chngproc(int netsock, const char *root, const char *challenge)

for (;;) {
op = CHNG__MAX;
if (0 == (lval = readop(netsock, COMM_CHNG_OP)))
if (0 == (lval = readop(netsock, COMM_CHNG_OP)))
op = CHNG_STOP;
else if (CHNG_SYN == lval)
op = lval;
Expand All @@ -76,7 +76,7 @@ chngproc(int netsock, const char *root, const char *challenge)

assert(CHNG_SYN == op);

/*
/*
* Read the thumbprint and token.
* The token is the filename, so store that in a vector
* of tokens that we'll later clean up.
Expand Down
4 changes: 2 additions & 2 deletions dbg.c
Expand Up @@ -27,7 +27,7 @@
void
doddbg(const char *fmt, ...)
{
va_list ap;
va_list ap;

if (verbose < 2)
return;
Expand All @@ -40,7 +40,7 @@ doddbg(const char *fmt, ...)
void
dodbg(const char *fmt, ...)
{
va_list ap;
va_list ap;

if ( ! verbose)
return;
Expand Down
4 changes: 2 additions & 2 deletions extern.h
Expand Up @@ -152,7 +152,7 @@ enum comm {
* (presumably!) local machine to an ACME connection; and a URI, to
* which we must connect to verify the token.
*/
struct chng {
struct chng {
char *uri; /* uri on ACME server */
char *token; /* token we must offer */
size_t retry; /* how many times have we tried */
Expand Down Expand Up @@ -246,7 +246,7 @@ char *json_fmt_protected_rsa(const char *,
char *json_fmt_revokecert(const char *);
char *json_fmt_header_rsa(const char *, const char *);
char *json_fmt_thumb_rsa(const char *, const char *);
char *json_fmt_signed(const char *,
char *json_fmt_signed(const char *,
const char *, const char *, const char *);

int dropprivs(void);
Expand Down

0 comments on commit 60b741f

Please sign in to comment.