/* FIPS Known answer tests for Qcrypto. * * Copyright (c) 2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef __CRYPTO_MSM_QCRYPTO_FIPS_H #define __CRYPTO_MSM_QCRYPTO_FIPS_H struct _fips_completion { struct completion completion; int err; }; /* * For cipher algorithms. */ struct _fips_test_vector_cipher { char *key; unsigned char klen; char iv[16]; unsigned char ivlen; char *pln_txt; unsigned int pln_txt_len; char *enc_txt; unsigned int enc_txt_len; char mod_alg[CRYPTO_MAX_ALG_NAME]; }; /* * For Hashing / HMAC algorithms. */ struct _fips_test_vector_sha_hmac { char *key; unsigned char klen; char *input; unsigned char ilen; char *digest; unsigned char diglen; char hash_alg[CRYPTO_MAX_ALG_NAME]; }; /* *For AEAD algorithms */ struct _fips_test_vector_aead { char *key; unsigned char klen; char iv[16]; unsigned char ivlen; char assoc[32]; unsigned char alen; char *pln_txt; unsigned int pln_txt_len; char *enc_txt; unsigned int enc_txt_len; char mod_alg[CRYPTO_MAX_ALG_NAME]; }; /* *Test vectors for sha/hmac tests */ static struct _fips_test_vector_sha_hmac fips_test_vector_sha_hmac[] = { /*http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA1.pdf*/ { /* SHA1 */ .hash_alg = "sha1", .klen = 0, .input = "abc", .ilen = 3, .digest = "\xa9\x99\x3e\x36\x47\x06\x81\x6a" "\xba\x3e\x25\x71\x78\x50\xc2\x6c" "\x9c\xd0\xd8\x9d", .diglen = SHA1_DIGEST_SIZE, }, /* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA256.pdf */ {/* SHA256 */ .hash_alg = "sha256", .klen = 0, .input = "abc", .ilen = 3, .digest = "\xba\x78\x16\xbf\x8f\x01\xcf\xea" "\x41\x41\x40\xde\x5d\xae\x22\x23" "\xb0\x03\x61\xa3\x96\x17\x7a\x9c" "\xb4\x10\xff\x61\xf2\x00\x15\xad", .diglen = SHA256_DIGEST_SIZE, }, /* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/HMAC_SHA1.pdf */ {/* HMAC-SHA1 */ .hash_alg = "hmac(sha1)", .key = "\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" "\x10\x11\x12\x13", .klen = 20, .input = "Sample message for keylen