Created
November 9, 2016 07:13
-
-
Save vdudouyt/9c946109f1c709b6d5835e77901800a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @seed: 20 bytes | |
* @result: 120 bytes (but use first 107 bytes only) | |
*/ | |
int mgf1(char *seed, BYTE *result) | |
{ | |
int hlen = 20; | |
int length = 127 - hlen; | |
int i, d = 0; | |
for(i = 0; i <= length; i += hlen) | |
{ | |
unsigned char C[4]; | |
SHA1_CTX ctx; | |
format_int(C, i, 4, MP_BIG_ENDIAN); | |
sha1_init(&ctx); | |
sha1_update(&ctx, seed, 20); | |
sha1_update(&ctx, C, 4); | |
sha1_final(&ctx, &result[d * 20]); | |
d++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment