sick

sign and check files using ed25519
Log | Files | Refs | Submodules | README | LICENSE

commit 3365573fd7ba9f5653418eeca336329047e1c983
parent c781b566414ba4ad22f2018c57f6876c23e5e0d9
Author: z3bra <willyatmailoodotorg>
Date:   Sun May  8 00:01:39 +12000

Declare base64_table[] in base64.c

Diffstat:
base64.c | 26++++++++++++++++++--------
base64.h | 8--------
base64.o | 0
3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/base64.c b/base64.c @@ -6,10 +6,18 @@ #include "base64.h" +const char base64_table[] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M', + 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + 'a','b','c','d','e','f','g','h','i','j','k','l','m', + 'n','o','p','q','r','s','t','u','v','w','x','y','z', + '0','1','2','3','4','5','6','7','8','9','+','/' +}; + size_t base64_encode(char **buf, const unsigned char *msg, size_t len) { - int i, j; + size_t i, j; uint64_t b64; size_t size; @@ -40,28 +48,30 @@ base64_decode(char **buf, const unsigned char *msg, size_t len) { size_t size; - size = 1 + (len / 4 ) * 3; + size = 1 + (len * 3) / 4; size -= msg[len - 1] == '=' ? 1 : 0; size -= msg[len - 2] == '=' ? 1 : 0; - printf("base64: %lu bytes\n", len); - printf("clear : %lu bytes\n", size); + *buf = malloc(size); + memset(*buf, 0, size); return size; } +/* int main(int argc, char *argv[]) { int i; size_t len, n; - char *buf = NULL, in[59]; + char *buf = NULL, in[79]; - while ((n = read(0, in, 57)) > 0) { - in[58] = 0; - len = base64_encode(&buf, in, n); + while ((n = read(0, in, 77)) > 0) { + in[78] = 0; + len = base64_decode(&buf, in, n); puts(buf); free(buf); } return 0; } +*/ diff --git a/base64.h b/base64.h @@ -4,12 +4,4 @@ size_t base64_encode(char **buf, const unsigned char *msg, size_t len); size_t base64_decode(char **buf, const unsigned char *msg, size_t len); -const char base64_table[] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M', - 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - 'a','b','c','d','e','f','g','h','i','j','k','l','m', - 'n','o','p','q','r','s','t','u','v','w','x','y','z', - '0','1','2','3','4','5','6','7','8','9','+','/' -}; - #endif diff --git a/base64.o b/base64.o Binary files differ