summaryrefslogtreecommitdiff
path: root/cmd/bltest
diff options
context:
space:
mode:
authorTim Taubert <ttaubert@mozilla.com>2016-02-10 08:17:28 +0100
committerTim Taubert <ttaubert@mozilla.com>2016-02-10 08:17:28 +0100
commit098dd9a56fed1dd4d21e7a54434ef6c5b9bb8ff6 (patch)
treeb716e032fab9d0b3696da785fc3c292eec08a86e /cmd/bltest
parent1c42c068014e548b0cdc5295efaee57133bf0fbc (diff)
downloadnss-hg-098dd9a56fed1dd4d21e7a54434ef6c5b9bb8ff6.tar.gz
Backed out changeset db4f87eed8ff (bug 917571)
Diffstat (limited to 'cmd/bltest')
-rw-r--r--cmd/bltest/blapitest.c174
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/aad01
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/aad1bin12 -> 0 bytes
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/ciphertext01
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/ciphertext11
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/iv0bin12 -> 0 bytes
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/iv1bin12 -> 0 bytes
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/key01
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/key11
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/numtests1
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/plaintext01
-rw-r--r--cmd/bltest/tests/chacha20_poly1305/plaintext11
12 files changed, 17 insertions, 165 deletions
diff --git a/cmd/bltest/blapitest.c b/cmd/bltest/blapitest.c
index 74de908dc..204814d82 100644
--- a/cmd/bltest/blapitest.c
+++ b/cmd/bltest/blapitest.c
@@ -613,17 +613,6 @@ typedef SECStatus (* bltestSymmCipherFn)(void *cx,
const unsigned char *input,
unsigned int inputLen);
-typedef SECStatus (* bltestAEADFn)(void *cx,
- unsigned char *output,
- unsigned int *outputLen,
- unsigned int maxOutputLen,
- const unsigned char *input,
- unsigned int inputLen,
- const unsigned char *nonce,
- unsigned int nonceLen,
- const unsigned char *ad,
- unsigned int adLen);
-
typedef SECStatus (* bltestPubKeyCipherFn)(void *key,
SECItem *output,
const SECItem *input);
@@ -657,7 +646,6 @@ typedef enum {
bltestCAMELLIA_CBC, /* . */
bltestSEED_ECB, /* SEED algorithm */
bltestSEED_CBC, /* SEED algorithm */
- bltestCHACHA20, /* ChaCha20 + Poly1305 */
bltestRSA, /* Public Key Ciphers */
bltestRSA_OAEP, /* . (Public Key Enc.) */
bltestRSA_PSS, /* . (Public Key Sig.) */
@@ -697,7 +685,6 @@ static char *mode_strings[] =
"camellia_cbc",
"seed_ecb",
"seed_cbc",
- "chacha20_poly1305",
"rsa",
"rsa_oaep",
"rsa_pss",
@@ -818,7 +805,6 @@ struct bltestCipherInfoStr {
/* Cipher function (encrypt/decrypt/sign/verify/hash) */
union {
bltestSymmCipherFn symmkeyCipher;
- bltestAEADFn aeadCipher;
bltestPubKeyCipherFn pubkeyCipher;
bltestHashCipherFn hashCipher;
} cipher;
@@ -841,28 +827,12 @@ is_symmkeyCipher(bltestCipherMode mode)
}
PRBool
-is_aeadCipher(bltestCipherMode mode)
-{
- /* change as needed! */
- switch (mode) {
- case bltestCHACHA20:
- return PR_TRUE;
- default:
- return PR_FALSE;
- }
-}
-
-PRBool
is_authCipher(bltestCipherMode mode)
{
/* change as needed! */
- switch (mode) {
- case bltestAES_GCM:
- case bltestCHACHA20:
- return PR_TRUE;
- default:
- return PR_FALSE;
- }
+ if (mode == bltestAES_GCM)
+ return PR_TRUE;
+ return PR_FALSE;
}
@@ -870,14 +840,11 @@ PRBool
is_singleShotCipher(bltestCipherMode mode)
{
/* change as needed! */
- switch (mode) {
- case bltestAES_GCM:
- case bltestAES_CTS:
- case bltestCHACHA20:
- return PR_TRUE;
- default:
- return PR_FALSE;
- }
+ if (mode == bltestAES_GCM)
+ return PR_TRUE;
+ if (mode == bltestAES_CTS)
+ return PR_TRUE;
+ return PR_FALSE;
}
PRBool
@@ -911,24 +878,16 @@ PRBool
cipher_requires_IV(bltestCipherMode mode)
{
/* change as needed! */
- switch (mode) {
- case bltestDES_CBC:
- case bltestDES_EDE_CBC:
- case bltestRC2_CBC:
+ if (mode == bltestDES_CBC || mode == bltestDES_EDE_CBC ||
+ mode == bltestRC2_CBC ||
#ifdef NSS_SOFTOKEN_DOES_RC5
- case bltestRC5_CBC:
+ mode == bltestRC5_CBC ||
#endif
- case bltestAES_CBC:
- case bltestAES_CTS:
- case bltestAES_CTR:
- case bltestAES_GCM:
- case bltestCAMELLIA_CBC:
- case bltestSEED_CBC:
- case bltestCHACHA20:
- return PR_TRUE;
- default:
- return PR_FALSE;
- }
+ mode == bltestAES_CBC || mode == bltestAES_CTS ||
+ mode == bltestAES_CTR || mode == bltestAES_GCM ||
+ mode == bltestCAMELLIA_CBC || mode == bltestSEED_CBC)
+ return PR_TRUE;
+ return PR_FALSE;
}
SECStatus finishIO(bltestIO *output, PRFileDesc *file);
@@ -1168,30 +1127,6 @@ aes_Decrypt(void *cx, unsigned char *output, unsigned int *outputLen,
}
SECStatus
-chacha20_poly1305_Encrypt(void *cx, unsigned char *output,
- unsigned int *outputLen, unsigned int maxOutputLen,
- const unsigned char *input, unsigned int inputLen,
- const unsigned char *nonce, unsigned int nonceLen,
- const unsigned char *ad, unsigned int adLen)
-{
- return ChaCha20Poly1305_Seal((ChaCha20Poly1305Context *)cx, output,
- outputLen, maxOutputLen, input, inputLen,
- nonce, nonceLen, ad, adLen);
-}
-
-SECStatus
-chacha20_poly1305_Decrypt(void *cx, unsigned char *output,
- unsigned int *outputLen, unsigned int maxOutputLen,
- const unsigned char *input, unsigned int inputLen,
- const unsigned char *nonce, unsigned int nonceLen,
- const unsigned char *ad, unsigned int adLen)
-{
- return ChaCha20Poly1305_Open((ChaCha20Poly1305Context *)cx, output,
- outputLen, maxOutputLen, input, inputLen,
- nonce, nonceLen, ad, adLen);
-}
-
-SECStatus
camellia_Encrypt(void *cx, unsigned char *output, unsigned int *outputLen,
unsigned int maxOutputLen, const unsigned char *input,
unsigned int inputLen)
@@ -1641,21 +1576,6 @@ bltest_seed_init(bltestCipherInfo *cipherInfo, PRBool encrypt)
}
SECStatus
-bltest_chacha20_init(bltestCipherInfo *cipherInfo, PRBool encrypt)
-{
- const unsigned int tagLen = 16;
- const bltestSymmKeyParams *sk = &cipherInfo->params.sk;
- cipherInfo->cx = ChaCha20Poly1305_CreateContext(sk->key.buf.data,
- sk->key.buf.len, tagLen);
-
- if (encrypt)
- cipherInfo->cipher.aeadCipher = chacha20_poly1305_Encrypt;
- else
- cipherInfo->cipher.aeadCipher = chacha20_poly1305_Decrypt;
- return SECSuccess;
-}
-
-SECStatus
bltest_rsa_init(bltestCipherInfo *cipherInfo, PRBool encrypt)
{
int i;
@@ -2306,11 +2226,6 @@ cipherInit(bltestCipherInfo *cipherInfo, PRBool encrypt)
cipherInfo->input.pBuf.len);
return bltest_seed_init(cipherInfo, encrypt);
break;
- case bltestCHACHA20:
- outlen = cipherInfo->input.pBuf.len + (encrypt ? 16 : 0);
- SECITEM_AllocItem(cipherInfo->arena, &cipherInfo->output.buf, outlen);
- return bltest_chacha20_init(cipherInfo, encrypt);
- break;
case bltestRSA:
case bltestRSA_OAEP:
case bltestRSA_PSS:
@@ -2461,55 +2376,6 @@ cipherDoOp(bltestCipherInfo *cipherInfo)
}
}
TIMEFINISH(cipherInfo->optime, 1.0);
- } else if (is_aeadCipher(cipherInfo->mode)) {
- const unsigned char *input = cipherInfo->input.pBuf.data;
- unsigned int inputLen = cipherInfo->input.pBuf.len;
- unsigned char *output = cipherInfo->output.pBuf.data;
- unsigned int outputLen;
- bltestSymmKeyParams *sk = &cipherInfo->params.sk;
- bltestAuthSymmKeyParams *ask = &cipherInfo->params.ask;
-
- TIMESTART();
- rv = (*cipherInfo->cipher.aeadCipher)(
- cipherInfo->cx,
- output, &outputLen, maxLen,
- input, inputLen,
- sk->iv.buf.data, sk->iv.buf.len,
- ask->aad.buf.data, ask->aad.buf.len);
- CHECKERROR(rv, __LINE__);
- cipherInfo->output.pBuf.len = outputLen;
- TIMEFINISH(cipherInfo->optime, 1.0);
-
- cipherInfo->repetitions = 0;
- if (cipherInfo->repetitionsToPerfom != 0) {
- TIMESTART();
- for (i=0; i<cipherInfo->repetitionsToPerfom; i++,
- cipherInfo->repetitions++) {
- rv = (*cipherInfo->cipher.aeadCipher)(
- cipherInfo->cx,
- output, &outputLen, maxLen,
- input, inputLen,
- sk->iv.buf.data, sk->iv.buf.len,
- ask->aad.buf.data, ask->aad.buf.len);
- CHECKERROR(rv, __LINE__);
- }
- } else {
- int opsBetweenChecks = 0;
- TIMEMARK(cipherInfo->seconds);
- while (! (TIMETOFINISH())) {
- int j = 0;
- for (;j < opsBetweenChecks;j++) {
- (*cipherInfo->cipher.aeadCipher)(
- cipherInfo->cx,
- output, &outputLen, maxLen,
- input, inputLen,
- sk->iv.buf.data, sk->iv.buf.len,
- ask->aad.buf.data, ask->aad.buf.len);
- }
- cipherInfo->repetitions += j;
- }
- }
- TIMEFINISH(cipherInfo->optime, 1.0);
} else if (is_pubkeyCipher(cipherInfo->mode)) {
TIMESTART();
rv = (*cipherInfo->cipher.pubkeyCipher)(cipherInfo->cx,
@@ -2611,10 +2477,6 @@ cipherFinish(bltestCipherInfo *cipherInfo)
case bltestSEED_CBC:
SEED_DestroyContext((SEEDContext *)cipherInfo->cx, PR_TRUE);
break;
- case bltestCHACHA20:
- ChaCha20Poly1305_DestroyContext((ChaCha20Poly1305Context *)
- cipherInfo->cx, PR_TRUE);
- break;
case bltestRC2_ECB:
case bltestRC2_CBC:
RC2_DestroyContext((RC2Context *)cipherInfo->cx, PR_TRUE);
@@ -2946,7 +2808,6 @@ get_params(PLArenaPool *arena, bltestParams *params,
#endif
switch (mode) {
case bltestAES_GCM:
- case bltestCHACHA20:
sprintf(filename, "%s/tests/%s/%s%d", testdir, modestr, "aad", j);
load_file_data(arena, &params->ask.aad, filename, bltestBinary);
case bltestDES_CBC:
@@ -3892,8 +3753,7 @@ print_usage:
/* Set up an encryption key. */
keysize = 0;
file = NULL;
- if (is_symmkeyCipher(cipherInfo->mode) ||
- is_aeadCipher(cipherInfo->mode)) {
+ if (is_symmkeyCipher(cipherInfo->mode)) {
char *keystr = NULL; /* if key is on command line */
if (bltest.options[opt_Key].activated) {
if (bltest.options[opt_CmdLine].activated) {
diff --git a/cmd/bltest/tests/chacha20_poly1305/aad0 b/cmd/bltest/tests/chacha20_poly1305/aad0
deleted file mode 100644
index a420ef184..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/aad0
+++ /dev/null
@@ -1 +0,0 @@
-PQRSΐΑΒΓΔΕΖΗ \ No newline at end of file
diff --git a/cmd/bltest/tests/chacha20_poly1305/aad1 b/cmd/bltest/tests/chacha20_poly1305/aad1
deleted file mode 100644
index 91287a1a2..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/aad1
+++ /dev/null
Binary files differ
diff --git a/cmd/bltest/tests/chacha20_poly1305/ciphertext0 b/cmd/bltest/tests/chacha20_poly1305/ciphertext0
deleted file mode 100644
index a06f68b5f..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/ciphertext0
+++ /dev/null
@@ -1 +0,0 @@
-0xqNNGSOYNt7hq+8U+9+wqSt7VEpbgj+qeK1pzbuYtY9vqRejKlnEoL6+2naknKLGnHeCp4GCykF1qW2fs07NpLdvX8td4uMmAOu4ygJG1j6syTk+tZ1lFWFgItIMde8P/Te8I5Lep3ldtJlhs7GS2EWGuELWU8J4mp+kC7L0GAGkQ==
diff --git a/cmd/bltest/tests/chacha20_poly1305/ciphertext1 b/cmd/bltest/tests/chacha20_poly1305/ciphertext1
deleted file mode 100644
index e7f0d0100..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/ciphertext1
+++ /dev/null
@@ -1 +0,0 @@
-ZKCGFXWGGvRg8GLHm+ZDvV6AXP00XPOJ8QhnCsdsjLJMbPwYdV1D7qCe6U44LSawvbe3PDIbAQDU8Dt/NViUzzMvgw5xC5fOmMioSr0LlIEUrRduAI0zvWD5grH/N8hVl5egbvTw72HBhjJOKzUGODYGkHtqfAKw+fYVe1PIZ+S5Fmx2e4BNRqWbUhbN56TpkEDFpAQzIl7igqGwoGxSPq9FNNf4P6EVWwBHcYy8VGoNBysEs1ZO6htCInP1SCcaC7IxYFP6dpkZVevWMVlDTs67TkZtrloQc6ZydicJehBJ5hfZHTYQlPpo8P93mHEwMFvqui7aBN+Ze3FNbG8sKaatXLQCKwJwm+6tnWeJDLsiOSM2/qGFHzg=
diff --git a/cmd/bltest/tests/chacha20_poly1305/iv0 b/cmd/bltest/tests/chacha20_poly1305/iv0
deleted file mode 100644
index 7e8a17504..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/iv0
+++ /dev/null
Binary files differ
diff --git a/cmd/bltest/tests/chacha20_poly1305/iv1 b/cmd/bltest/tests/chacha20_poly1305/iv1
deleted file mode 100644
index 7c8b98f50..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/iv1
+++ /dev/null
Binary files differ
diff --git a/cmd/bltest/tests/chacha20_poly1305/key0 b/cmd/bltest/tests/chacha20_poly1305/key0
deleted file mode 100644
index 503ecb84e..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/key0
+++ /dev/null
@@ -1 +0,0 @@
-€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ \ No newline at end of file
diff --git a/cmd/bltest/tests/chacha20_poly1305/key1 b/cmd/bltest/tests/chacha20_poly1305/key1
deleted file mode 100644
index 002bf1b45..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/key1
+++ /dev/null
@@ -1 +0,0 @@
-’@₯λUӊσ3ˆ†φ΅πG9Α@+€ Κ\Ό puΐ \ No newline at end of file
diff --git a/cmd/bltest/tests/chacha20_poly1305/numtests b/cmd/bltest/tests/chacha20_poly1305/numtests
deleted file mode 100644
index 0cfbf0888..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/numtests
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/cmd/bltest/tests/chacha20_poly1305/plaintext0 b/cmd/bltest/tests/chacha20_poly1305/plaintext0
deleted file mode 100644
index 74c222908..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/plaintext0
+++ /dev/null
@@ -1 +0,0 @@
-Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it. \ No newline at end of file
diff --git a/cmd/bltest/tests/chacha20_poly1305/plaintext1 b/cmd/bltest/tests/chacha20_poly1305/plaintext1
deleted file mode 100644
index 029317d8e..000000000
--- a/cmd/bltest/tests/chacha20_poly1305/plaintext1
+++ /dev/null
@@ -1 +0,0 @@
-Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as /β€œwork in progress./” \ No newline at end of file