crypto: testmgr - Added testvectors for the rfc3686(ctr(sm4)) skcipher
authorPascal van Leeuwen <pascalvanl@gmail.com>
Fri, 13 Sep 2019 09:10:42 +0000 (11:10 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 4 Oct 2019 15:06:05 +0000 (01:06 +1000)
Added testvectors for the rfc3686(ctr(sm4)) skcipher algorithm

changes since v1:
- nothing

Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c
crypto/testmgr.h

index abfafffbcfe155f34b7dc34ad807e88869c44acd..82084f6d84b6a83d280746d842a8d6e712f26bf6 100644 (file)
@@ -4846,6 +4846,12 @@ static const struct alg_test_desc alg_test_descs[] = {
                .suite = {
                        .cipher = __VECS(aes_ctr_rfc3686_tv_template)
                }
+       }, {
+               .alg = "rfc3686(ctr(sm4))",
+               .test = alg_test_skcipher,
+               .suite = {
+                       .cipher = __VECS(sm4_ctr_rfc3686_tv_template)
+               }
        }, {
                .alg = "rfc4106(gcm(aes))",
                .generic_driver = "rfc4106(gcm_base(ctr(aes-generic),ghash-generic))",
index 9ac9d1e052284aa2a3f70b29b95fea478b7b8a28..d1d89101f1b55350325dfa4e87a5e4bdf0f30356 100644 (file)
@@ -11902,6 +11902,35 @@ static const struct cipher_testvec sm4_ctr_tv_template[] = {
        }
 };
 
+static const struct cipher_testvec sm4_ctr_rfc3686_tv_template[] = {
+       {
+               .key    = "\xae\x68\x52\xf8\x12\x10\x67\xcc"
+                         "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e"
+                         "\x00\x00\x00\x30",
+               .klen   = 20,
+               .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00",
+               .ptext  = "Single block msg",
+               .ctext  = "\x20\x9b\x77\x31\xd3\x65\xdb\xab"
+                         "\x9e\x48\x74\x7e\xbd\x13\x83\xeb",
+               .len    = 16,
+       }, {
+               .key    = "\x7e\x24\x06\x78\x17\xfa\xe0\xd7"
+                         "\x43\xd6\xce\x1f\x32\x53\x91\x63"
+                         "\x00\x6c\xb6\xdb",
+               .klen   = 20,
+               .iv     = "\xc0\x54\x3b\x59\xda\x48\xd9\x0b",
+               .ptext  = "\x00\x01\x02\x03\x04\x05\x06\x07"
+                         "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+                         "\x10\x11\x12\x13\x14\x15\x16\x17"
+                         "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+               .ctext  = "\x33\xe0\x28\x01\x92\xed\xc9\x1e"
+                         "\x97\x35\xd9\x4a\xec\xd4\xbc\x23"
+                         "\x4f\x35\x9f\x1c\x55\x1f\xe0\x27"
+                         "\xe0\xdf\xc5\x43\xbc\xb0\x23\x94",
+               .len    = 32,
+       }
+};
+
 static const struct cipher_testvec sm4_ofb_tv_template[] = {
        { /* From: draft-ribose-cfrg-sm4-02, paragraph 12.2.3 */
                .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"