aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.h
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/tcrypt.h')
-rw-r--r--crypto/tcrypt.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index f7f9b2379270..b91585ea1362 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -173,6 +173,33 @@ static struct hash_testvec sha1_tv_template[] = {
173 } 173 }
174}; 174};
175 175
176
177/*
178 * SHA224 test vectors from from FIPS PUB 180-2
179 */
180#define SHA224_TEST_VECTORS 2
181
182static struct hash_testvec sha224_tv_template[] = {
183 {
184 .plaintext = "abc",
185 .psize = 3,
186 .digest = { 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22,
187 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3,
188 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7,
189 0xE3, 0x6C, 0x9D, 0xA7},
190 }, {
191 .plaintext =
192 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
193 .psize = 56,
194 .digest = { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC,
195 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50,
196 0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19,
197 0x52, 0x52, 0x25, 0x25 },
198 .np = 2,
199 .tap = { 28, 28 }
200 }
201};
202
176/* 203/*
177 * SHA256 test vectors from from NIST 204 * SHA256 test vectors from from NIST
178 */ 205 */
@@ -817,6 +844,121 @@ static struct hash_testvec hmac_sha1_tv_template[] = {
817 }, 844 },
818}; 845};
819 846
847
848/*
849 * SHA224 HMAC test vectors from RFC4231
850 */
851#define HMAC_SHA224_TEST_VECTORS 4
852
853static struct hash_testvec hmac_sha224_tv_template[] = {
854 {
855 .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
856 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
857 0x0b, 0x0b, 0x0b, 0x0b },
858 .ksize = 20,
859 /* ("Hi There") */
860 .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 },
861 .psize = 8,
862 .digest = { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19,
863 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f,
864 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f,
865 0x53, 0x68, 0x4b, 0x22},
866 }, {
867 .key = { 0x4a, 0x65, 0x66, 0x65 }, /* ("Jefe") */
868 .ksize = 4,
869 /* ("what do ya want for nothing?") */
870 .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
871 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
872 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
873 0x69, 0x6e, 0x67, 0x3f },
874 .psize = 28,
875 .digest = { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
876 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
877 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00,
878 0x8f, 0xd0, 0x5e, 0x44 },
879 .np = 4,
880 .tap = { 7, 7, 7, 7 }
881 }, {
882 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
883 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
884 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
885 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
886 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
887 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
888 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
889 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
890 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
891 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
892 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
893 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
894 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
895 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
896 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
897 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
898 0xaa, 0xaa, 0xaa },
899 .ksize = 131,
900 /* ("Test Using Larger Than Block-Size Key - Hash Key First") */
901 .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
902 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65,
903 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
904 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a,
905 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
906 0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79,
907 0x20, 0x46, 0x69, 0x72, 0x73, 0x74 },
908 .psize = 54,
909 .digest = { 0x95, 0xe9, 0xa0, 0xdb, 0x96, 0x20, 0x95, 0xad,
910 0xae, 0xbe, 0x9b, 0x2d, 0x6f, 0x0d, 0xbc, 0xe2,
911 0xd4, 0x99, 0xf1, 0x12, 0xf2, 0xd2, 0xb7, 0x27,
912 0x3f, 0xa6, 0x87, 0x0e },
913 }, {
914 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
915 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
916 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
917 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
918 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
919 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
920 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
921 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
922 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
923 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
924 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
925 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
926 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
927 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
928 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
929 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
930 0xaa, 0xaa, 0xaa },
931 .ksize = 131,
932 /* ("This is a test using a larger than block-size key and a")
933 (" larger than block-size data. The key needs to be")
934 (" hashed before being used by the HMAC algorithm.") */
935 .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
936 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75,
937 0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
938 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68,
939 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
940 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65,
941 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
942 0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74,
943 0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
944 0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64,
945 0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
946 0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65,
947 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
948 0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20,
949 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
950 0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65,
951 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
952 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c,
953 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e },
954 .psize = 152,
955 .digest = { 0x3a, 0x85, 0x41, 0x66, 0xac, 0x5d, 0x9f, 0x02,
956 0x3f, 0x54, 0xd5, 0x17, 0xd0, 0xb3, 0x9d, 0xbd,
957 0x94, 0x67, 0x70, 0xdb, 0x9c, 0x2b, 0x95, 0xc9,
958 0xf6, 0xf5, 0x65, 0xd1 },
959 },
960};
961
820/* 962/*
821 * HMAC-SHA256 test vectors from 963 * HMAC-SHA256 test vectors from
822 * draft-ietf-ipsec-ciph-sha-256-01.txt 964 * draft-ietf-ipsec-ciph-sha-256-01.txt