tDeclare base64_table[] in base64.c - sick - sign and check files using ed25519
(HTM) git clone git://z3bra.org/sick
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 3365573fd7ba9f5653418eeca336329047e1c983
(DIR) parent c781b566414ba4ad22f2018c57f6876c23e5e0d9
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Sun, 8 May 2016 00:01:39 +0200
Declare base64_table[] in base64.c
Diffstat:
M base64.c | 26 ++++++++++++++++++--------
M base64.h | 8 --------
A base64.o | 0
3 files changed, 18 insertions(+), 16 deletions(-)
---
(DIR) diff --git a/base64.c b/base64.c
t@@ -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;
t@@ -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;
}
+*/
(DIR) diff --git a/base64.h b/base64.h
t@@ -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
(DIR) diff --git a/base64.o b/base64.o
Binary files differ.