summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-11-25 14:03:59 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-11-25 14:03:59 +0100
commitbe5ca42e8d5f36145cca6c2120899e7e2ad4f0b3 (patch)
tree82128dc2958a2ff9a295ecba1c6c78073d2676d3
parent23d0d8caf42b6b55e531b2405d949c6606ed3e85 (diff)
downloadbusybox-w32-be5ca42e8d5f36145cca6c2120899e7e2ad4f0b3.tar.gz
busybox-w32-be5ca42e8d5f36145cca6c2120899e7e2ad4f0b3.tar.bz2
busybox-w32-be5ca42e8d5f36145cca6c2120899e7e2ad4f0b3.zip
tls: code shrink
function old new delta aesgcm_GHASH 223 196 -27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/tls.c2
-rw-r--r--networking/tls_aesgcm.c18
2 files changed, 14 insertions, 6 deletions
diff --git a/networking/tls.c b/networking/tls.c
index 7bdd58018..85a4e21dd 100644
--- a/networking/tls.c
+++ b/networking/tls.c
@@ -867,7 +867,6 @@ static void xwrite_encrypted_aesgcm(tls_state_t *tls, unsigned size, unsigned ty
867 xorbuf_aligned_AES_BLOCK_SIZE(authtag, scratch); 867 xorbuf_aligned_AES_BLOCK_SIZE(authtag, scratch);
868 868
869 memcpy(buf, authtag, sizeof(authtag)); 869 memcpy(buf, authtag, sizeof(authtag));
870#undef COUNTER
871 870
872 /* Write out */ 871 /* Write out */
873 xhdr = (void*)(tls->outbuf + OUTBUF_PFX - 8 - RECHDR_LEN); 872 xhdr = (void*)(tls->outbuf + OUTBUF_PFX - 8 - RECHDR_LEN);
@@ -881,6 +880,7 @@ static void xwrite_encrypted_aesgcm(tls_state_t *tls, unsigned size, unsigned ty
881 dump_raw_out(">> %s\n", xhdr, size); 880 dump_raw_out(">> %s\n", xhdr, size);
882 xwrite(tls->ofd, xhdr, size); 881 xwrite(tls->ofd, xhdr, size);
883 dbg("wrote %u bytes\n", size); 882 dbg("wrote %u bytes\n", size);
883#undef COUNTER
884} 884}
885 885
886static void xwrite_encrypted(tls_state_t *tls, unsigned size, unsigned type) 886static void xwrite_encrypted(tls_state_t *tls, unsigned size, unsigned type)
diff --git a/networking/tls_aesgcm.c b/networking/tls_aesgcm.c
index 32ca40260..688df85fb 100644
--- a/networking/tls_aesgcm.c
+++ b/networking/tls_aesgcm.c
@@ -87,8 +87,8 @@ void FAST_FUNC aesgcm_GHASH(byte* h,
87) 87)
88{ 88{
89 byte x[AES_BLOCK_SIZE] ALIGNED_long; 89 byte x[AES_BLOCK_SIZE] ALIGNED_long;
90 byte scratch[AES_BLOCK_SIZE] ALIGNED_long; 90// byte scratch[AES_BLOCK_SIZE] ALIGNED_long;
91 word32 blocks, partial; 91 unsigned blocks, partial;
92 //was: byte* h = aes->H; 92 //was: byte* h = aes->H;
93 93
94 //XMEMSET(x, 0, AES_BLOCK_SIZE); 94 //XMEMSET(x, 0, AES_BLOCK_SIZE);
@@ -133,9 +133,17 @@ void FAST_FUNC aesgcm_GHASH(byte* h,
133 } 133 }
134 134
135 /* Hash in the lengths of A and C in bits */ 135 /* Hash in the lengths of A and C in bits */
136 FlattenSzInBits(&scratch[0], aSz); 136 //FlattenSzInBits(&scratch[0], aSz);
137 FlattenSzInBits(&scratch[8], cSz); 137 //FlattenSzInBits(&scratch[8], cSz);
138 xorbuf_aligned_AES_BLOCK_SIZE(x, scratch); 138 //xorbuf_aligned_AES_BLOCK_SIZE(x, scratch);
139 // simpler:
140#define P32(v) ((uint32_t*)v)
141 //P32(x)[0] ^= 0;
142 P32(x)[1] ^= SWAP_BE32(aSz * 8);
143 //P32(x)[2] ^= 0;
144 P32(x)[3] ^= SWAP_BE32(cSz * 8);
145#undef P32
146
139 GMULT(x, h); 147 GMULT(x, h);
140 148
141 /* Copy the result into s. */ 149 /* Copy the result into s. */