diff options
| author | Benedict <benedict@0xb8000.de> | 2017-02-21 12:59:34 +0100 |
|---|---|---|
| committer | Benedict <benedict@0xb8000.de> | 2017-02-21 13:00:25 +0100 |
| commit | 2930ba4f32680e245c1dae66197153abdf6502a6 (patch) | |
| tree | 996ab8ec48bae9ef87abb6bdd994d9dadc2b564f /lib/lib2.c | |
| parent | ddce9b2d44ab48fc566870c5155b39c8fc06f24d (diff) | |
added lib to git and moved set2 to subdir
Diffstat (limited to 'lib/lib2.c')
| -rw-r--r-- | lib/lib2.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/lib2.c b/lib/lib2.c new file mode 100644 index 0000000..86dd823 --- /dev/null +++ b/lib/lib2.c @@ -0,0 +1,23 @@ +#include "lib2.h" + +/** + * appends PKCS#7 padding to string. devide string in blocks of size blocksize + * and append to last block so that it is also of blocksize length + */ + +char *pkcs7_padding(char *string, int length_string, int blocksize) +{ + char *result = NULL; + int i; + int value = blocksize - (length_string % blocksize); + + result = malloc(length_string+value+1); + memcpy(result, string, length_string); + + for(i=0;i<value;i++) { + result[length_string+i] = (char) value; + } + result[length_string+i] = '\0'; + + return result; +} |
