/*
- * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
static void remove_space(char **pval)
{
- unsigned char *p = (unsigned char *)*pval;
+ unsigned char *p = (unsigned char *)*pval, *beginning;
while (isspace(*p))
p++;
- *pval = (char *)p;
+ *pval = (char *)(beginning = p);
p = p + strlen(*pval) - 1;
/* Remove trailing space */
- while (isspace(*p))
+ while (p >= beginning && isspace(*p))
*p-- = 0;
}
EVP_CIPHER_CTX_set_padding(ctx, 0);
err = "CIPHERUPDATE_ERROR";
tmplen = 0;
- donelen = 0;
if (!frag) {
/* We supply the data all in one go */
if (!EVP_CipherUpdate(ctx, tmp + out_misalign, &tmplen, in, in_len))
if (!EVP_CipherUpdate(ctx, tmp + out_misalign, &chunklen, in, 1))
goto err;
tmplen += chunklen;
- donelen = 1;
+ in++;
+ in_len--;
}
- if (in_len > 2) {
+ if (in_len > 1) {
if (!EVP_CipherUpdate(ctx, tmp + out_misalign + tmplen, &chunklen,
- in + donelen, in_len - 2))
+ in, in_len - 1))
goto err;
tmplen += chunklen;
- donelen += in_len - 2;
+ in += in_len - 1;
+ in_len = 1;
}
- if (in_len > 1 ) {
+ if (in_len > 0 ) {
if (!EVP_CipherUpdate(ctx, tmp + out_misalign + tmplen, &chunklen,
- in + donelen, 1))
+ in, 1))
goto err;
tmplen += chunklen;
}
}
- if (cdat->aead == EVP_CIPH_CCM_MODE)
- tmpflen = 0;
- else {
- err = "CIPHERFINAL_ERROR";
- if (!EVP_CipherFinal_ex(ctx, tmp + out_misalign + tmplen, &tmpflen))
- goto err;
- }
+ err = "CIPHERFINAL_ERROR";
+ if (!EVP_CipherFinal_ex(ctx, tmp + out_misalign + tmplen, &tmpflen))
+ goto err;
err = "LENGTH_MISMATCH";
if (out_len != (size_t)(tmplen + tmpflen))
goto err;
#else
t->skip = 1;
return 1;
+#endif
+ } else if (strcmp(alg, "SipHash") == 0) {
+#ifndef OPENSSL_NO_SIPHASH
+ type = EVP_PKEY_SIPHASH;
+#else
+ t->skip = 1;
+ return 1;
#endif
} else
return 0;
size_t mac_len;
#ifdef OPENSSL_NO_DES
- if (strstr(mdata->alg, "DES") != NULL) {
+ if (mdata->alg != NULL && strstr(mdata->alg, "DES") != NULL) {
/* Skip DES */
err = NULL;
goto err;