diff options
Diffstat (limited to 'crypto/testmgr.c')
| -rw-r--r-- | crypto/testmgr.c | 243 | 
1 files changed, 213 insertions, 30 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index e091ef6e179..498649ac195 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -179,7 +179,7 @@ static int do_one_async_hash_op(struct ahash_request *req,  		ret = wait_for_completion_interruptible(&tr->completion);  		if (!ret)  			ret = tr->err; -		INIT_COMPLETION(tr->completion); +		reinit_completion(&tr->completion);  	}  	return ret;  } @@ -336,7 +336,7 @@ static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,  				ret = wait_for_completion_interruptible(  					&tresult.completion);  				if (!ret && !(ret = tresult.err)) { -					INIT_COMPLETION(tresult.completion); +					reinit_completion(&tresult.completion);  					break;  				}  				/* fall through */ @@ -414,16 +414,18 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  	void *input;  	void *output;  	void *assoc; -	char iv[MAX_IVLEN]; +	char *iv;  	char *xbuf[XBUFSIZE];  	char *xoutbuf[XBUFSIZE];  	char *axbuf[XBUFSIZE]; +	iv = kzalloc(MAX_IVLEN, GFP_KERNEL); +	if (!iv) +		return ret;  	if (testmgr_alloc_buf(xbuf))  		goto out_noxbuf;  	if (testmgr_alloc_buf(axbuf))  		goto out_noaxbuf; -  	if (diff_dst && testmgr_alloc_buf(xoutbuf))  		goto out_nooutbuf; @@ -503,16 +505,16 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  				goto out;  			} -			sg_init_one(&sg[0], input, -				    template[i].ilen + (enc ? authsize : 0)); -  			if (diff_dst) {  				output = xoutbuf[0];  				output += align_offset; +				sg_init_one(&sg[0], input, template[i].ilen);  				sg_init_one(&sgout[0], output, +					    template[i].rlen); +			} else { +				sg_init_one(&sg[0], input,  					    template[i].ilen +  						(enc ? authsize : 0)); -			} else {  				output = input;  			} @@ -543,7 +545,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  				ret = wait_for_completion_interruptible(  					&result.completion);  				if (!ret && !(ret = result.err)) { -					INIT_COMPLETION(result.completion); +					reinit_completion(&result.completion);  					break;  				}  			case -EBADMSG: @@ -612,12 +614,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  				memcpy(q, template[i].input + temp,  				       template[i].tap[k]); -				n = template[i].tap[k]; -				if (k == template[i].np - 1 && enc) -					n += authsize; -				if (offset_in_page(q) + n < PAGE_SIZE) -					q[n] = 0; -  				sg_set_buf(&sg[k], q, template[i].tap[k]);  				if (diff_dst) { @@ -625,13 +621,17 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  					    offset_in_page(IDX[k]);  					memset(q, 0, template[i].tap[k]); -					if (offset_in_page(q) + n < PAGE_SIZE) -						q[n] = 0;  					sg_set_buf(&sgout[k], q,  						   template[i].tap[k]);  				} +				n = template[i].tap[k]; +				if (k == template[i].np - 1 && enc) +					n += authsize; +				if (offset_in_page(q) + n < PAGE_SIZE) +					q[n] = 0; +  				temp += template[i].tap[k];  			} @@ -650,10 +650,10 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  					goto out;  				} -				sg[k - 1].length += authsize; -  				if (diff_dst)  					sgout[k - 1].length += authsize; +				else +					sg[k - 1].length += authsize;  			}  			sg_init_table(asg, template[i].anp); @@ -697,7 +697,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc,  				ret = wait_for_completion_interruptible(  					&result.completion);  				if (!ret && !(ret = result.err)) { -					INIT_COMPLETION(result.completion); +					reinit_completion(&result.completion);  					break;  				}  			case -EBADMSG: @@ -769,6 +769,7 @@ out_nooutbuf:  out_noaxbuf:  	testmgr_free_buf(xbuf);  out_noxbuf: +	kfree(iv);  	return ret;  } @@ -983,7 +984,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,  				ret = wait_for_completion_interruptible(  					&result.completion);  				if (!ret && !((ret = result.err))) { -					INIT_COMPLETION(result.completion); +					reinit_completion(&result.completion);  					break;  				}  				/* fall through */ @@ -1086,7 +1087,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,  				ret = wait_for_completion_interruptible(  					&result.completion);  				if (!ret && !((ret = result.err))) { -					INIT_COMPLETION(result.completion); +					reinit_completion(&result.completion);  					break;  				}  				/* fall through */ @@ -1811,14 +1812,108 @@ static const struct alg_test_desc alg_test_descs[] = {  			}  		}  	}, { +		.alg = "authenc(hmac(md5),ecb(cipher_null))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = hmac_md5_ecb_cipher_null_enc_tv_template, +					.count = HMAC_MD5_ECB_CIPHER_NULL_ENC_TEST_VECTORS +				}, +				.dec = { +					.vecs = hmac_md5_ecb_cipher_null_dec_tv_template, +					.count = HMAC_MD5_ECB_CIPHER_NULL_DEC_TEST_VECTORS +				} +			} +		} +	}, {  		.alg = "authenc(hmac(sha1),cbc(aes))",  		.test = alg_test_aead,  		.fips_allowed = 1,  		.suite = {  			.aead = {  				.enc = { -					.vecs = hmac_sha1_aes_cbc_enc_tv_template, -					.count = HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS +					.vecs = +					hmac_sha1_aes_cbc_enc_tv_temp, +					.count = +					HMAC_SHA1_AES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha1),cbc(des))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha1_des_cbc_enc_tv_temp, +					.count = +					HMAC_SHA1_DES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha1),cbc(des3_ede))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha1_des3_ede_cbc_enc_tv_temp, +					.count = +					HMAC_SHA1_DES3_EDE_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha1),ecb(cipher_null))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha1_ecb_cipher_null_enc_tv_temp, +					.count = +					HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VEC +				}, +				.dec = { +					.vecs = +					hmac_sha1_ecb_cipher_null_dec_tv_temp, +					.count = +					HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha224),cbc(des))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha224_des_cbc_enc_tv_temp, +					.count = +					HMAC_SHA224_DES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha224),cbc(des3_ede))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha224_des3_ede_cbc_enc_tv_temp, +					.count = +					HMAC_SHA224_DES3_EDE_CBC_ENC_TEST_VEC  				}  			}  		} @@ -1829,8 +1924,66 @@ static const struct alg_test_desc alg_test_descs[] = {  		.suite = {  			.aead = {  				.enc = { -					.vecs = hmac_sha256_aes_cbc_enc_tv_template, -					.count = HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS +					.vecs = +					hmac_sha256_aes_cbc_enc_tv_temp, +					.count = +					HMAC_SHA256_AES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha256),cbc(des))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha256_des_cbc_enc_tv_temp, +					.count = +					HMAC_SHA256_DES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha256),cbc(des3_ede))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha256_des3_ede_cbc_enc_tv_temp, +					.count = +					HMAC_SHA256_DES3_EDE_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha384),cbc(des))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha384_des_cbc_enc_tv_temp, +					.count = +					HMAC_SHA384_DES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha384),cbc(des3_ede))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha384_des3_ede_cbc_enc_tv_temp, +					.count = +					HMAC_SHA384_DES3_EDE_CBC_ENC_TEST_VEC  				}  			}  		} @@ -1841,8 +1994,38 @@ static const struct alg_test_desc alg_test_descs[] = {  		.suite = {  			.aead = {  				.enc = { -					.vecs = hmac_sha512_aes_cbc_enc_tv_template, -					.count = HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS +					.vecs = +					hmac_sha512_aes_cbc_enc_tv_temp, +					.count = +					HMAC_SHA512_AES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha512),cbc(des))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha512_des_cbc_enc_tv_temp, +					.count = +					HMAC_SHA512_DES_CBC_ENC_TEST_VEC +				} +			} +		} +	}, { +		.alg = "authenc(hmac(sha512),cbc(des3_ede))", +		.test = alg_test_aead, +		.fips_allowed = 1, +		.suite = { +			.aead = { +				.enc = { +					.vecs = +					hmac_sha512_des3_ede_cbc_enc_tv_temp, +					.count = +					HMAC_SHA512_DES3_EDE_CBC_ENC_TEST_VEC  				}  			}  		} @@ -3243,8 +3426,8 @@ test_done:  		panic("%s: %s alg self test failed in fips mode!\n", driver, alg);  	if (fips_enabled && !rc) -		printk(KERN_INFO "alg: self-tests for %s (%s) passed\n", -		       driver, alg); +		pr_info(KERN_INFO "alg: self-tests for %s (%s) passed\n", +			driver, alg);  	return rc;  | 
