]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Take advantage of PUT_32BIT_MSB_FIRST when constructing sequence numbers
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 20 Feb 2013 22:37:34 +0000 (22:37 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 20 Feb 2013 22:37:34 +0000 (22:37 +0000)
to MAC.

[originally from svn r9758]

sshmd5.c
sshsha.c

index e5187a661662b4b793330055f717222b503a0572..2fdb5900703327cf065a5455b38b40d66e084821 100644 (file)
--- a/sshmd5.c
+++ b/sshmd5.c
@@ -312,11 +312,7 @@ static void hmacmd5_do_hmac_ssh(void *handle, unsigned char const *blk, int len,
 {
     unsigned char seqbuf[16];
 
-    seqbuf[0] = (unsigned char) ((seq >> 24) & 0xFF);
-    seqbuf[1] = (unsigned char) ((seq >> 16) & 0xFF);
-    seqbuf[2] = (unsigned char) ((seq >> 8) & 0xFF);
-    seqbuf[3] = (unsigned char) ((seq) & 0xFF);
-
+    PUT_32BIT_MSB_FIRST(seqbuf, seq);
     hmacmd5_do_hmac_internal(handle, seqbuf, 4, blk, len, hmac);
 }
 
index 30113511b44527819c5c4d6a858c8b53bef823e7..b2493f2f58b762310d2a0b3b4211050c3d7aed1e 100644 (file)
--- a/sshsha.c
+++ b/sshsha.c
@@ -297,11 +297,7 @@ static void sha1_do_hmac(void *handle, unsigned char *blk, int len,
 {
     unsigned char seqbuf[4];
 
-    seqbuf[0] = (unsigned char) ((seq >> 24) & 0xFF);
-    seqbuf[1] = (unsigned char) ((seq >> 16) & 0xFF);
-    seqbuf[2] = (unsigned char) ((seq >> 8) & 0xFF);
-    seqbuf[3] = (unsigned char) ((seq) & 0xFF);
-
+    PUT_32BIT_MSB_FIRST(seqbuf, seq);
     hmacsha1_start(handle);
     hmacsha1_bytes(handle, seqbuf, 4);
     hmacsha1_bytes(handle, blk, len);