]> git.baikalelectronics.ru Git - kernel.git/commitdiff
crypto: testmgr - Added testvectors for the ofb(sm4) & cfb(sm4) skciphers
authorPascal van Leeuwen <pascalvanl@gmail.com>
Fri, 13 Sep 2019 09:10:39 +0000 (11:10 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 4 Oct 2019 15:06:04 +0000 (01:06 +1000)
Added testvectors for the ofb(sm4) and cfb(sm4) skcipher algorithms

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 40d94ad706d408f5db73c740ef9c18d5b4d68d75..abfafffbcfe155f34b7dc34ad807e88869c44acd 100644 (file)
@@ -4125,6 +4125,12 @@ static const struct alg_test_desc alg_test_descs[] = {
                .suite = {
                        .cipher = __VECS(aes_cfb_tv_template)
                },
+       }, {
+               .alg = "cfb(sm4)",
+               .test = alg_test_skcipher,
+               .suite = {
+                       .cipher = __VECS(sm4_cfb_tv_template)
+               }
        }, {
                .alg = "chacha20",
                .test = alg_test_skcipher,
@@ -4796,6 +4802,12 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "ofb(paes)",
                .test = alg_test_null,
                .fips_allowed = 1,
+       }, {
+               .alg = "ofb(sm4)",
+               .test = alg_test_skcipher,
+               .suite = {
+                       .cipher = __VECS(sm4_ofb_tv_template)
+               }
        }, {
                .alg = "pcbc(fcrypt)",
                .test = alg_test_skcipher,
index 56ee6264bde9e384ac681c48da231ab6a23f1b44..9ac9d1e052284aa2a3f70b29b95fea478b7b8a28 100644 (file)
@@ -11902,6 +11902,104 @@ static const struct cipher_testvec sm4_ctr_tv_template[] = {
        }
 };
 
+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"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .klen   = 16,
+               .iv     = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .ptext  = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+                         "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .ctext  = "\x69\x3d\x9a\x53\x5b\xad\x5b\xb1"
+                         "\x78\x6f\x53\xd7\x25\x3a\x70\x56"
+                         "\xf2\x07\x5d\x28\xb5\x23\x5f\x58"
+                         "\xd5\x00\x27\xe4\x17\x7d\x2b\xce",
+               .len    = 32,
+       }, { /* From: draft-ribose-cfrg-sm4-09, appendix A.2.3, Example 1 */
+               .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .klen   = 16,
+               .iv     = "\x00\x01\x02\x03\x04\x05\x06\x07"
+                         "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+               .ptext  = "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb"
+                         "\xcc\xcc\xcc\xcc\xdd\xdd\xdd\xdd"
+                         "\xee\xee\xee\xee\xff\xff\xff\xff"
+                         "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb",
+               .ctext  = "\xac\x32\x36\xcb\x86\x1d\xd3\x16"
+                         "\xe6\x41\x3b\x4e\x3c\x75\x24\xb7"
+                         "\x1d\x01\xac\xa2\x48\x7c\xa5\x82"
+                         "\xcb\xf5\x46\x3e\x66\x98\x53\x9b",
+               .len    = 32,
+       }, { /* From: draft-ribose-cfrg-sm4-09, appendix A.2.3, Example 2 */
+               .key    = "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+                         "\x01\x23\x45\x67\x89\xab\xcd\xef",
+               .klen   = 16,
+               .iv     = "\x00\x01\x02\x03\x04\x05\x06\x07"
+                         "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+               .ptext  = "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb"
+                         "\xcc\xcc\xcc\xcc\xdd\xdd\xdd\xdd"
+                         "\xee\xee\xee\xee\xff\xff\xff\xff"
+                         "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb",
+               .ctext  = "\x5d\xcc\xcd\x25\xa8\x4b\xa1\x65"
+                         "\x60\xd7\xf2\x65\x88\x70\x68\x49"
+                         "\x33\xfa\x16\xbd\x5c\xd9\xc8\x56"
+                         "\xca\xca\xa1\xe1\x01\x89\x7a\x97",
+               .len    = 32,
+       }
+};
+
+static const struct cipher_testvec sm4_cfb_tv_template[] = {
+       { /* From: draft-ribose-cfrg-sm4-02, paragraph 12.2.4 */
+               .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .klen   = 16,
+               .iv     = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .ptext  = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+                         "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .ctext  = "\x69\x3d\x9a\x53\x5b\xad\x5b\xb1"
+                         "\x78\x6f\x53\xd7\x25\x3a\x70\x56"
+                         "\x9e\xd2\x58\xa8\x5a\x04\x67\xcc"
+                         "\x92\xaa\xb3\x93\xdd\x97\x89\x95",
+               .len    = 32,
+       }, { /* From: draft-ribose-cfrg-sm4-09, appendix A.2.4, Example 1 */
+               .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+                         "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+               .klen   = 16,
+               .iv     = "\x00\x01\x02\x03\x04\x05\x06\x07"
+                         "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+               .ptext  = "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb"
+                         "\xcc\xcc\xcc\xcc\xdd\xdd\xdd\xdd"
+                         "\xee\xee\xee\xee\xff\xff\xff\xff"
+                         "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb",
+               .ctext  = "\xac\x32\x36\xcb\x86\x1d\xd3\x16"
+                         "\xe6\x41\x3b\x4e\x3c\x75\x24\xb7"
+                         "\x69\xd4\xc5\x4e\xd4\x33\xb9\xa0"
+                         "\x34\x60\x09\xbe\xb3\x7b\x2b\x3f",
+               .len    = 32,
+       }, { /* From: draft-ribose-cfrg-sm4-09, appendix A.2.4, Example 2 */
+               .key    = "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+                         "\x01\x23\x45\x67\x89\xab\xcd\xef",
+               .klen   = 16,
+               .iv     = "\x00\x01\x02\x03\x04\x05\x06\x07"
+                         "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+               .ptext  = "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb"
+                         "\xcc\xcc\xcc\xcc\xdd\xdd\xdd\xdd"
+                         "\xee\xee\xee\xee\xff\xff\xff\xff"
+                         "\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb",
+               .ctext  = "\x5d\xcc\xcd\x25\xa8\x4b\xa1\x65"
+                         "\x60\xd7\xf2\x65\x88\x70\x68\x49"
+                         "\x0d\x9b\x86\xff\x20\xc3\xbf\xe1"
+                         "\x15\xff\xa0\x2c\xa6\x19\x2c\xc5",
+               .len    = 32,
+       }
+};
+
 /* Cast6 test vectors from RFC 2612 */
 static const struct cipher_testvec cast6_tv_template[] = {
        {