diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-19 15:51:00 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-19 15:51:00 +0100 |
commit | 6b1b004845ebec194c4d4868d3deb57f22711b19 (patch) | |
tree | 291b2cf65b5537a184369eabec0089420ed63930 /networking/tls_aes.c | |
parent | 1bfc4b85a7915210936edc62ecf0d01a17751222 (diff) | |
download | busybox-w32-6b1b004845ebec194c4d4868d3deb57f22711b19.tar.gz busybox-w32-6b1b004845ebec194c4d4868d3deb57f22711b19.tar.bz2 busybox-w32-6b1b004845ebec194c4d4868d3deb57f22711b19.zip |
tls: commented out psPool_t use
function old new delta
psAesEncrypt 159 162 +3
der_binary_to_pstm 42 40 -2
xwrite_and_hash 437 434 -3
xread_tls_block 446 443 -3
pstm_div_2d 449 444 -5
psAesDecrypt 179 174 -5
pstm_init_size 52 45 -7
pstm_init 46 39 -7
pstm_to_unsigned_bin 165 157 -8
tls_main 1265 1256 -9
pstm_mulmod 132 123 -9
pstm_mod 125 116 -9
pstm_init_copy 93 84 -9
psAesInitKey 840 825 -15
send_client_key_exchange 362 342 -20
psAesInit 103 80 -23
psRsaEncryptPub 429 403 -26
psAesDecryptBlock 1211 1184 -27
psAesEncryptBlock 1223 1193 -30
pstm_exptmod 1582 1524 -58
pstm_div 1557 1472 -85
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/20 up/down: 3/-360) Total: -357 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/tls_aes.c')
-rw-r--r-- | networking/tls_aes.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/networking/tls_aes.c b/networking/tls_aes.c index 661bd8272..6c3c39373 100644 --- a/networking/tls_aes.c +++ b/networking/tls_aes.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include "tls.h" | 6 | #include "tls.h" |
7 | 7 | ||
8 | /* The file is taken almost verbatim from matrixssl-3-7-2b-open/crypto/symmetric/. | 8 | /* The file is taken almost verbatim from matrixssl-3-7-2b-open/crypto/symmetric/. |
9 | * Changes are flagged with ///bbox | 9 | * Changes are flagged with //bbox |
10 | */ | 10 | */ |
11 | 11 | ||
12 | /** | 12 | /** |
@@ -43,7 +43,7 @@ | |||
43 | */ | 43 | */ |
44 | /******************************************************************************/ | 44 | /******************************************************************************/ |
45 | 45 | ||
46 | ///vda | 46 | //bbox |
47 | //#include "../cryptoApi.h" | 47 | //#include "../cryptoApi.h" |
48 | 48 | ||
49 | #ifdef USE_AES | 49 | #ifdef USE_AES |
@@ -1084,10 +1084,11 @@ int32 psAesInit(psCipherContext_t *ctx, unsigned char *IV, | |||
1084 | { | 1084 | { |
1085 | int32 x, err; | 1085 | int32 x, err; |
1086 | 1086 | ||
1087 | if (IV == NULL || key == NULL || ctx == NULL) { | 1087 | //bbox |
1088 | psTraceCrypto("psAesInit arg fail\n"); | 1088 | // if (IV == NULL || key == NULL || ctx == NULL) { |
1089 | return PS_ARG_FAIL; | 1089 | // psTraceCrypto("psAesInit arg fail\n"); |
1090 | } | 1090 | // return PS_ARG_FAIL; |
1091 | // } | ||
1091 | memset(ctx, 0x0, sizeof(psCipherContext_t)); | 1092 | memset(ctx, 0x0, sizeof(psCipherContext_t)); |
1092 | /* | 1093 | /* |
1093 | setup cipher | 1094 | setup cipher |
@@ -1112,10 +1113,13 @@ int32 psAesEncrypt(psCipherContext_t *ctx, unsigned char *pt, | |||
1112 | uint32 i; | 1113 | uint32 i; |
1113 | unsigned char tmp[MAXBLOCKSIZE]; | 1114 | unsigned char tmp[MAXBLOCKSIZE]; |
1114 | 1115 | ||
1115 | if (pt == NULL || ct == NULL || ctx == NULL || (len & 0x7) != 0) { | 1116 | //bbox |
1116 | psTraceCrypto("Bad parameters to psAesEncrypt\n"); | 1117 | // if (pt == NULL || ct == NULL || ctx == NULL || (len & 0x7) != 0) { |
1117 | return PS_ARG_FAIL; | 1118 | // psTraceCrypto("Bad parameters to psAesEncrypt\n"); |
1118 | } | 1119 | // return PS_ARG_FAIL; |
1120 | // } | ||
1121 | if ((len & 0x7) != 0) | ||
1122 | bb_error_msg_and_die("AES len:%d", len); | ||
1119 | 1123 | ||
1120 | /* | 1124 | /* |
1121 | is blocklen valid? | 1125 | is blocklen valid? |
@@ -1159,10 +1163,13 @@ int32 psAesDecrypt(psCipherContext_t *ctx, unsigned char *ct, | |||
1159 | uint32 i; | 1163 | uint32 i; |
1160 | unsigned char tmp[MAXBLOCKSIZE], tmp2[MAXBLOCKSIZE]; | 1164 | unsigned char tmp[MAXBLOCKSIZE], tmp2[MAXBLOCKSIZE]; |
1161 | 1165 | ||
1162 | if (pt == NULL || ct == NULL || ctx == NULL || (len & 0x7) != 0) { | 1166 | //bbox |
1163 | psTraceCrypto("Bad parameters to psAesDecrypt\n"); | 1167 | // if (pt == NULL || ct == NULL || ctx == NULL || (len & 0x7) != 0) { |
1164 | return PS_ARG_FAIL; | 1168 | // psTraceCrypto("Bad parameters to psAesDecrypt\n"); |
1165 | } | 1169 | // return PS_ARG_FAIL; |
1170 | // } | ||
1171 | if ((len & 0x7) != 0) | ||
1172 | bb_error_msg_and_die("AES len:%d", len); | ||
1166 | 1173 | ||
1167 | /* | 1174 | /* |
1168 | is blocklen valid? | 1175 | is blocklen valid? |
@@ -1221,14 +1228,15 @@ int32 psAesInitKey(const unsigned char *key, uint32 keylen, psAesKey_t *skey) | |||
1221 | int32 i, j; | 1228 | int32 i, j; |
1222 | uint32 temp, *rk, *rrk; | 1229 | uint32 temp, *rk, *rrk; |
1223 | 1230 | ||
1224 | if (key == NULL || skey == NULL) { | 1231 | //bbox |
1225 | psTraceCrypto("Bad args to psAesInitKey\n"); | 1232 | // if (key == NULL || skey == NULL) { |
1226 | return PS_ARG_FAIL; | 1233 | // psTraceCrypto("Bad args to psAesInitKey\n"); |
1227 | } | 1234 | // return PS_ARG_FAIL; |
1235 | // } | ||
1228 | 1236 | ||
1229 | if (keylen != 16 && keylen != 24 && keylen != 32) { | 1237 | if (keylen != 16 && keylen != 24 && keylen != 32) { |
1230 | psTraceCrypto("Invalid AES key length\n"); | 1238 | psTraceCrypto("Invalid AES key length\n"); |
1231 | ///bbox return CRYPT_INVALID_KEYSIZE; | 1239 | //bbox return CRYPT_INVALID_KEYSIZE; |
1232 | //unreachable anyway | 1240 | //unreachable anyway |
1233 | return PS_ARG_FAIL; | 1241 | return PS_ARG_FAIL; |
1234 | } | 1242 | } |
@@ -1398,9 +1406,10 @@ void psAesEncryptBlock(const unsigned char *pt, unsigned char *ct, | |||
1398 | uint32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; | 1406 | uint32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; |
1399 | int32 Nr, r; | 1407 | int32 Nr, r; |
1400 | 1408 | ||
1401 | if (pt == NULL || ct == NULL || skey == NULL) { | 1409 | //bbox |
1402 | return; | 1410 | // if (pt == NULL || ct == NULL || skey == NULL) { |
1403 | } | 1411 | // return; |
1412 | // } | ||
1404 | 1413 | ||
1405 | Nr = skey->Nr; | 1414 | Nr = skey->Nr; |
1406 | rk = skey->eK; | 1415 | rk = skey->eK; |
@@ -1562,9 +1571,10 @@ void psAesDecryptBlock(const unsigned char *ct, unsigned char *pt, | |||
1562 | uint32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; | 1571 | uint32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; |
1563 | int32 Nr, r; | 1572 | int32 Nr, r; |
1564 | 1573 | ||
1565 | if (pt == NULL || ct == NULL || skey == NULL) { | 1574 | //bbox |
1566 | return; | 1575 | // if (pt == NULL || ct == NULL || skey == NULL) { |
1567 | } | 1576 | // return; |
1577 | // } | ||
1568 | 1578 | ||
1569 | Nr = skey->Nr; | 1579 | Nr = skey->Nr; |
1570 | rk = skey->dK; | 1580 | rk = skey->dK; |