diff options
author | mav <mav@FreeBSD.org> | 2008-12-16 19:15:31 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2008-12-16 19:15:31 +0000 |
commit | 1290464fbc7b41e44c7d1bde1b834fc4559ad746 (patch) | |
tree | a12b97fc6f773be6ef1a590073ec52d007b122a3 /sys/netgraph | |
parent | 99f3b7b788594678d9c1c7b7f587b70facecb930 (diff) | |
download | FreeBSD-src-1290464fbc7b41e44c7d1bde1b834fc4559ad746.zip FreeBSD-src-1290464fbc7b41e44c7d1bde1b834fc4559ad746.tar.gz |
Unroll two loops of SHA1Update(). 60 bytes of static memory is not a price.
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/ng_mppc.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c index 472968f..5a6c302 100644 --- a/sys/netgraph/ng_mppc.c +++ b/sys/netgraph/ng_mppc.c @@ -824,21 +824,24 @@ ng_mppc_reset_req(node_p node) static void ng_mppc_getkey(const u_char *h, u_char *h2, int len) { - static const u_char pad1[10] = - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static const u_char pad2[10] = - { 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, }; + static const u_char pad1[40] = + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const u_char pad2[40] = + { 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, + 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, + 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, + 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2 }; u_char hash[20]; SHA1_CTX c; - int k; SHA1Init(&c); SHA1Update(&c, h, len); - for (k = 0; k < 4; k++) - SHA1Update(&c, pad1, sizeof(pad1)); + SHA1Update(&c, pad1, sizeof(pad1)); SHA1Update(&c, h2, len); - for (k = 0; k < 4; k++) - SHA1Update(&c, pad2, sizeof(pad2)); + SHA1Update(&c, pad2, sizeof(pad2)); SHA1Final(hash, &c); bcopy(hash, h2, len); } |