diff options
author | Sebastian Siewior <sebastian@breakpoint.cc> | 2008-03-11 09:24:26 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-04-20 22:19:21 -0400 |
commit | 477035c2abdcff7583369e5777cb7be1bb1dbea8 (patch) | |
tree | 797db8233c052ae8128e28c304d15fa8e25c1b68 /crypto | |
parent | 78f8b3a24022c48fe600f4aba415d63ceeaec9cd (diff) |
[CRYPTO] tcrypt: Group common speed templates
Some crypto ciphers which are impleneted support similar key sizes
(16,24 & 32 byte). They can be grouped together and use a common
templatte instead of their own which contains the same data.
Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/tcrypt.c | 70 | ||||
-rw-r--r-- | crypto/tcrypt.h | 158 |
2 files changed, 91 insertions, 137 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 1ab8c017a011..cff18364fbc1 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -1621,89 +1621,85 @@ static void do_test(void) | |||
1621 | 1621 | ||
1622 | case 200: | 1622 | case 200: |
1623 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, | 1623 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
1624 | aes_speed_template); | 1624 | speed_template_16_24_32); |
1625 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, | 1625 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
1626 | aes_speed_template); | 1626 | speed_template_16_24_32); |
1627 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, | 1627 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
1628 | aes_speed_template); | 1628 | speed_template_16_24_32); |
1629 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, | 1629 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
1630 | aes_speed_template); | 1630 | speed_template_16_24_32); |
1631 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, | 1631 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
1632 | aes_lrw_speed_template); | 1632 | speed_template_32_40_48); |
1633 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, | 1633 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
1634 | aes_lrw_speed_template); | 1634 | speed_template_32_40_48); |
1635 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, | 1635 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
1636 | aes_xts_speed_template); | 1636 | speed_template_32_48_64); |
1637 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, | 1637 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
1638 | aes_xts_speed_template); | 1638 | speed_template_32_48_64); |
1639 | break; | 1639 | break; |
1640 | 1640 | ||
1641 | case 201: | 1641 | case 201: |
1642 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, | 1642 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
1643 | des3_ede_enc_tv_template, | 1643 | des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS, |
1644 | DES3_EDE_ENC_TEST_VECTORS, | 1644 | speed_template_24); |
1645 | des3_ede_speed_template); | ||
1646 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, | 1645 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
1647 | des3_ede_dec_tv_template, | 1646 | des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS, |
1648 | DES3_EDE_DEC_TEST_VECTORS, | 1647 | speed_template_24); |
1649 | des3_ede_speed_template); | ||
1650 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, | 1648 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
1651 | des3_ede_enc_tv_template, | 1649 | des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS, |
1652 | DES3_EDE_ENC_TEST_VECTORS, | 1650 | speed_template_24); |
1653 | des3_ede_speed_template); | ||
1654 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, | 1651 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
1655 | des3_ede_dec_tv_template, | 1652 | des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS, |
1656 | DES3_EDE_DEC_TEST_VECTORS, | 1653 | speed_template_24); |
1657 | des3_ede_speed_template); | ||
1658 | break; | 1654 | break; |
1659 | 1655 | ||
1660 | case 202: | 1656 | case 202: |
1661 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, | 1657 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
1662 | twofish_speed_template); | 1658 | speed_template_16_24_32); |
1663 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, | 1659 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
1664 | twofish_speed_template); | 1660 | speed_template_16_24_32); |
1665 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, | 1661 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
1666 | twofish_speed_template); | 1662 | speed_template_16_24_32); |
1667 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, | 1663 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
1668 | twofish_speed_template); | 1664 | speed_template_16_24_32); |
1669 | break; | 1665 | break; |
1670 | 1666 | ||
1671 | case 203: | 1667 | case 203: |
1672 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, | 1668 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
1673 | blowfish_speed_template); | 1669 | speed_template_8_32); |
1674 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, | 1670 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
1675 | blowfish_speed_template); | 1671 | speed_template_8_32); |
1676 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, | 1672 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
1677 | blowfish_speed_template); | 1673 | speed_template_8_32); |
1678 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, | 1674 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
1679 | blowfish_speed_template); | 1675 | speed_template_8_32); |
1680 | break; | 1676 | break; |
1681 | 1677 | ||
1682 | case 204: | 1678 | case 204: |
1683 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, | 1679 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
1684 | des_speed_template); | 1680 | speed_template_8); |
1685 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, | 1681 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
1686 | des_speed_template); | 1682 | speed_template_8); |
1687 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, | 1683 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
1688 | des_speed_template); | 1684 | speed_template_8); |
1689 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, | 1685 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
1690 | des_speed_template); | 1686 | speed_template_8); |
1691 | break; | 1687 | break; |
1692 | 1688 | ||
1693 | case 205: | 1689 | case 205: |
1694 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, | 1690 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
1695 | camellia_speed_template); | 1691 | speed_template_16_24_32); |
1696 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, | 1692 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
1697 | camellia_speed_template); | 1693 | speed_template_16_24_32); |
1698 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, | 1694 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
1699 | camellia_speed_template); | 1695 | speed_template_16_24_32); |
1700 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, | 1696 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
1701 | camellia_speed_template); | 1697 | speed_template_16_24_32); |
1702 | break; | 1698 | break; |
1703 | 1699 | ||
1704 | case 206: | 1700 | case 206: |
1705 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, | 1701 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, |
1706 | salsa20_speed_template); | 1702 | speed_template_16_32); |
1707 | break; | 1703 | break; |
1708 | 1704 | ||
1709 | case 300: | 1705 | case 300: |
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h index f785e5618e11..4180a7463e4e 100644 --- a/crypto/tcrypt.h +++ b/crypto/tcrypt.h | |||
@@ -8032,7 +8032,62 @@ static struct hash_testvec crc32c_tv_template[] = { | |||
8032 | /* | 8032 | /* |
8033 | * Cipher speed tests | 8033 | * Cipher speed tests |
8034 | */ | 8034 | */ |
8035 | static struct cipher_speed aes_speed_template[] = { | 8035 | static struct cipher_speed speed_template_8[] = { |
8036 | { .klen = 8, .blen = 16, }, | ||
8037 | { .klen = 8, .blen = 64, }, | ||
8038 | { .klen = 8, .blen = 256, }, | ||
8039 | { .klen = 8, .blen = 1024, }, | ||
8040 | { .klen = 8, .blen = 8192, }, | ||
8041 | |||
8042 | /* End marker */ | ||
8043 | { .klen = 0, .blen = 0, } | ||
8044 | }; | ||
8045 | |||
8046 | static struct cipher_speed speed_template_24[] = { | ||
8047 | { .klen = 24, .blen = 16, }, | ||
8048 | { .klen = 24, .blen = 64, }, | ||
8049 | { .klen = 24, .blen = 256, }, | ||
8050 | { .klen = 24, .blen = 1024, }, | ||
8051 | { .klen = 24, .blen = 8192, }, | ||
8052 | |||
8053 | /* End marker */ | ||
8054 | { .klen = 0, .blen = 0, } | ||
8055 | }; | ||
8056 | |||
8057 | static struct cipher_speed speed_template_8_32[] = { | ||
8058 | /* Don't support blowfish keys > 256 bit in this test */ | ||
8059 | { .klen = 8, .blen = 16, }, | ||
8060 | { .klen = 8, .blen = 64, }, | ||
8061 | { .klen = 8, .blen = 256, }, | ||
8062 | { .klen = 8, .blen = 1024, }, | ||
8063 | { .klen = 8, .blen = 8192, }, | ||
8064 | { .klen = 32, .blen = 16, }, | ||
8065 | { .klen = 32, .blen = 64, }, | ||
8066 | { .klen = 32, .blen = 256, }, | ||
8067 | { .klen = 32, .blen = 1024, }, | ||
8068 | { .klen = 32, .blen = 8192, }, | ||
8069 | |||
8070 | /* End marker */ | ||
8071 | { .klen = 0, .blen = 0, } | ||
8072 | }; | ||
8073 | |||
8074 | static struct cipher_speed speed_template_16_32[] = { | ||
8075 | { .klen = 16, .blen = 16, }, | ||
8076 | { .klen = 16, .blen = 64, }, | ||
8077 | { .klen = 16, .blen = 256, }, | ||
8078 | { .klen = 16, .blen = 1024, }, | ||
8079 | { .klen = 16, .blen = 8192, }, | ||
8080 | { .klen = 32, .blen = 16, }, | ||
8081 | { .klen = 32, .blen = 64, }, | ||
8082 | { .klen = 32, .blen = 256, }, | ||
8083 | { .klen = 32, .blen = 1024, }, | ||
8084 | { .klen = 32, .blen = 8192, }, | ||
8085 | |||
8086 | /* End marker */ | ||
8087 | { .klen = 0, .blen = 0, } | ||
8088 | }; | ||
8089 | |||
8090 | static struct cipher_speed speed_template_16_24_32[] = { | ||
8036 | { .klen = 16, .blen = 16, }, | 8091 | { .klen = 16, .blen = 16, }, |
8037 | { .klen = 16, .blen = 64, }, | 8092 | { .klen = 16, .blen = 64, }, |
8038 | { .klen = 16, .blen = 256, }, | 8093 | { .klen = 16, .blen = 256, }, |
@@ -8053,7 +8108,7 @@ static struct cipher_speed aes_speed_template[] = { | |||
8053 | { .klen = 0, .blen = 0, } | 8108 | { .klen = 0, .blen = 0, } |
8054 | }; | 8109 | }; |
8055 | 8110 | ||
8056 | static struct cipher_speed aes_lrw_speed_template[] = { | 8111 | static struct cipher_speed speed_template_32_40_48[] = { |
8057 | { .klen = 32, .blen = 16, }, | 8112 | { .klen = 32, .blen = 16, }, |
8058 | { .klen = 32, .blen = 64, }, | 8113 | { .klen = 32, .blen = 64, }, |
8059 | { .klen = 32, .blen = 256, }, | 8114 | { .klen = 32, .blen = 256, }, |
@@ -8074,7 +8129,7 @@ static struct cipher_speed aes_lrw_speed_template[] = { | |||
8074 | { .klen = 0, .blen = 0, } | 8129 | { .klen = 0, .blen = 0, } |
8075 | }; | 8130 | }; |
8076 | 8131 | ||
8077 | static struct cipher_speed aes_xts_speed_template[] = { | 8132 | static struct cipher_speed speed_template_32_48_64[] = { |
8078 | { .klen = 32, .blen = 16, }, | 8133 | { .klen = 32, .blen = 16, }, |
8079 | { .klen = 32, .blen = 64, }, | 8134 | { .klen = 32, .blen = 64, }, |
8080 | { .klen = 32, .blen = 256, }, | 8135 | { .klen = 32, .blen = 256, }, |
@@ -8095,66 +8150,6 @@ static struct cipher_speed aes_xts_speed_template[] = { | |||
8095 | { .klen = 0, .blen = 0, } | 8150 | { .klen = 0, .blen = 0, } |
8096 | }; | 8151 | }; |
8097 | 8152 | ||
8098 | static struct cipher_speed des3_ede_speed_template[] = { | ||
8099 | { .klen = 24, .blen = 16, }, | ||
8100 | { .klen = 24, .blen = 64, }, | ||
8101 | { .klen = 24, .blen = 256, }, | ||
8102 | { .klen = 24, .blen = 1024, }, | ||
8103 | { .klen = 24, .blen = 8192, }, | ||
8104 | |||
8105 | /* End marker */ | ||
8106 | { .klen = 0, .blen = 0, } | ||
8107 | }; | ||
8108 | |||
8109 | static struct cipher_speed twofish_speed_template[] = { | ||
8110 | { .klen = 16, .blen = 16, }, | ||
8111 | { .klen = 16, .blen = 64, }, | ||
8112 | { .klen = 16, .blen = 256, }, | ||
8113 | { .klen = 16, .blen = 1024, }, | ||
8114 | { .klen = 16, .blen = 8192, }, | ||
8115 | { .klen = 24, .blen = 16, }, | ||
8116 | { .klen = 24, .blen = 64, }, | ||
8117 | { .klen = 24, .blen = 256, }, | ||
8118 | { .klen = 24, .blen = 1024, }, | ||
8119 | { .klen = 24, .blen = 8192, }, | ||
8120 | { .klen = 32, .blen = 16, }, | ||
8121 | { .klen = 32, .blen = 64, }, | ||
8122 | { .klen = 32, .blen = 256, }, | ||
8123 | { .klen = 32, .blen = 1024, }, | ||
8124 | { .klen = 32, .blen = 8192, }, | ||
8125 | |||
8126 | /* End marker */ | ||
8127 | { .klen = 0, .blen = 0, } | ||
8128 | }; | ||
8129 | |||
8130 | static struct cipher_speed blowfish_speed_template[] = { | ||
8131 | /* Don't support blowfish keys > 256 bit in this test */ | ||
8132 | { .klen = 8, .blen = 16, }, | ||
8133 | { .klen = 8, .blen = 64, }, | ||
8134 | { .klen = 8, .blen = 256, }, | ||
8135 | { .klen = 8, .blen = 1024, }, | ||
8136 | { .klen = 8, .blen = 8192, }, | ||
8137 | { .klen = 32, .blen = 16, }, | ||
8138 | { .klen = 32, .blen = 64, }, | ||
8139 | { .klen = 32, .blen = 256, }, | ||
8140 | { .klen = 32, .blen = 1024, }, | ||
8141 | { .klen = 32, .blen = 8192, }, | ||
8142 | |||
8143 | /* End marker */ | ||
8144 | { .klen = 0, .blen = 0, } | ||
8145 | }; | ||
8146 | |||
8147 | static struct cipher_speed des_speed_template[] = { | ||
8148 | { .klen = 8, .blen = 16, }, | ||
8149 | { .klen = 8, .blen = 64, }, | ||
8150 | { .klen = 8, .blen = 256, }, | ||
8151 | { .klen = 8, .blen = 1024, }, | ||
8152 | { .klen = 8, .blen = 8192, }, | ||
8153 | |||
8154 | /* End marker */ | ||
8155 | { .klen = 0, .blen = 0, } | ||
8156 | }; | ||
8157 | |||
8158 | /* | 8153 | /* |
8159 | * Digest speed tests | 8154 | * Digest speed tests |
8160 | */ | 8155 | */ |
@@ -8186,41 +8181,4 @@ static struct hash_speed generic_hash_speed_template[] = { | |||
8186 | { .blen = 0, .plen = 0, } | 8181 | { .blen = 0, .plen = 0, } |
8187 | }; | 8182 | }; |
8188 | 8183 | ||
8189 | static struct cipher_speed camellia_speed_template[] = { | ||
8190 | { .klen = 16, .blen = 16, }, | ||
8191 | { .klen = 16, .blen = 64, }, | ||
8192 | { .klen = 16, .blen = 256, }, | ||
8193 | { .klen = 16, .blen = 1024, }, | ||
8194 | { .klen = 16, .blen = 8192, }, | ||
8195 | { .klen = 24, .blen = 16, }, | ||
8196 | { .klen = 24, .blen = 64, }, | ||
8197 | { .klen = 24, .blen = 256, }, | ||
8198 | { .klen = 24, .blen = 1024, }, | ||
8199 | { .klen = 24, .blen = 8192, }, | ||
8200 | { .klen = 32, .blen = 16, }, | ||
8201 | { .klen = 32, .blen = 64, }, | ||
8202 | { .klen = 32, .blen = 256, }, | ||
8203 | { .klen = 32, .blen = 1024, }, | ||
8204 | { .klen = 32, .blen = 8192, }, | ||
8205 | |||
8206 | /* End marker */ | ||
8207 | { .klen = 0, .blen = 0, } | ||
8208 | }; | ||
8209 | |||
8210 | static struct cipher_speed salsa20_speed_template[] = { | ||
8211 | { .klen = 16, .blen = 16, }, | ||
8212 | { .klen = 16, .blen = 64, }, | ||
8213 | { .klen = 16, .blen = 256, }, | ||
8214 | { .klen = 16, .blen = 1024, }, | ||
8215 | { .klen = 16, .blen = 8192, }, | ||
8216 | { .klen = 32, .blen = 16, }, | ||
8217 | { .klen = 32, .blen = 64, }, | ||
8218 | { .klen = 32, .blen = 256, }, | ||
8219 | { .klen = 32, .blen = 1024, }, | ||
8220 | { .klen = 32, .blen = 8192, }, | ||
8221 | |||
8222 | /* End marker */ | ||
8223 | { .klen = 0, .blen = 0, } | ||
8224 | }; | ||
8225 | |||
8226 | #endif /* _CRYPTO_TCRYPT_H */ | 8184 | #endif /* _CRYPTO_TCRYPT_H */ |