mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
common: use ccan/base64 instead of libsodium.
For consistency. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ff276e958b
commit
35c7f56c73
@ -1,15 +1,16 @@
|
|||||||
|
#include "config.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ccan/base64/base64.h>
|
||||||
#include <common/base64.h>
|
#include <common/base64.h>
|
||||||
#include <sodium/utils.h>
|
|
||||||
|
|
||||||
/* Decode/encode from/to base64, base64 helper functions.
|
|
||||||
* We import base64 from libsodium to generate tor V3 ED25519-V3 onions from blobs
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/* Decode/encode from/to base64, base64 helper functions.*/
|
||||||
char *b64_encode(const tal_t *ctx, const void *data, size_t len)
|
char *b64_encode(const tal_t *ctx, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
char *str = tal_arr(ctx, char, sodium_base64_encoded_len(len, sodium_base64_VARIANT_ORIGINAL) + 1);
|
size_t slen = base64_encoded_length(len), enclen;
|
||||||
|
char *str = tal_arr(ctx, char, slen + 1);
|
||||||
|
enclen = base64_encode(str, slen, data, len);
|
||||||
|
assert(enclen == slen);
|
||||||
|
|
||||||
str = sodium_bin2base64(str, tal_count(str), data,
|
str[enclen] = '\0';
|
||||||
len, sodium_base64_VARIANT_ORIGINAL);
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user