equal
deleted
inserted
replaced
34 //#include "stdafx.h" |
34 //#include "stdafx.h" |
35 |
35 |
36 |
36 |
37 #include <libc/string.h> /* for memcpy() etc. */ |
37 #include <libc/string.h> /* for memcpy() etc. */ |
38 #include <libc/stdlib.h> /* for _lrotl with VC++ */ |
38 #include <libc/stdlib.h> /* for _lrotl with VC++ */ |
|
39 |
|
40 #if defined(__GNUC__) || defined(__GNU_LIBRARY__) |
|
41 #include <byteswap.h> |
|
42 #include <endian.h> |
|
43 #endif |
39 |
44 |
40 #include "sha1.h" |
45 #include "sha1.h" |
41 #include "hmac.h" |
46 #include "hmac.h" |
42 |
47 |
43 void derive_key(const unsigned char pwd[], /* the PASSWORD */ |
48 void derive_key(const unsigned char pwd[], /* the PASSWORD */ |
206 sha1_end(cx->key, cx->ctx); /* store the result as the */ |
211 sha1_end(cx->key, cx->ctx); /* store the result as the */ |
207 cx->klen = OUT_BLOCK_LENGTH; /* key and set new length */ |
212 cx->klen = OUT_BLOCK_LENGTH; /* key and set new length */ |
208 } |
213 } |
209 |
214 |
210 /* pad the key if necessary */ |
215 /* pad the key if necessary */ |
|
216 //coverity[overrun-local] |
211 memset(cx->key + cx->klen, 0, IN_BLOCK_LENGTH - cx->klen); |
217 memset(cx->key + cx->klen, 0, IN_BLOCK_LENGTH - cx->klen); |
212 |
218 |
213 /* xor ipad into key value */ |
219 /* xor ipad into key value */ |
214 for(i = 0; i < (IN_BLOCK_LENGTH >> 2); ++i) |
220 for(i = 0; i < (IN_BLOCK_LENGTH >> 2); ++i) |
215 ((unsigned long*)cx->key)[i] ^= 0x36363636; |
221 ((unsigned long*)cx->key)[i] ^= 0x36363636; |