Commit a06b15b2 authored by Pascal van Leeuwen's avatar Pascal van Leeuwen Committed by Herbert Xu

crypto: testmgr - Added testvectors for the ofb(sm4) & cfb(sm4) skciphers

Added testvectors for the ofb(sm4) and cfb(sm4) skcipher algorithms

changes since v1:
- nothing
Signed-off-by: default avatarPascal van Leeuwen <pvanleeuwen@verimatrix.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 03a6cfb9
......@@ -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,
......
......@@ -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[] = {
{
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment