From 5890099fa89918e76bd9e15c94daae3a067aec6d Mon Sep 17 00:00:00 2001 From: Paul Wayper Date: Sun, 25 Oct 2015 11:24:16 +1100 Subject: [PATCH 1/2] Added 'base64url' mapping to choose from (using not yet provided 'choose map' mechanism). --- ccan/base64/base64.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ccan/base64/base64.c b/ccan/base64/base64.c index 5e75dd71c..c26e9fb56 100644 --- a/ccan/base64/base64.c +++ b/ccan/base64/base64.c @@ -252,3 +252,51 @@ static const base64_maps_t base64_maps_rfc4648 = { "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 245 */ }; + +/** + * base64url_maps_rfc4648 - rfc4648 'base64url' map with -_ rather than +/ + */ +static const base64_maps_t base64_maps_rfc4648 = { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", + + "\xff\xff\xff\xff\xff" /* 0 */ \ + "\xff\xff\xff\xff\xff" /* 5 */ \ + "\xff\xff\xff\xff\xff" /* 10 */ \ + "\xff\xff\xff\xff\xff" /* 15 */ \ + "\xff\xff\xff\xff\xff" /* 20 */ \ + "\xff\xff\xff\xff\xff" /* 25 */ \ + "\xff\xff\xff\xff\xff" /* 30 */ \ + "\xff\xff\xff\xff\xff" /* 35 */ \ + "\xff\xff\xff\xff\xff" /* 40 */ \ + "\x3e\xff\xff\x34\x35" /* 45 */ \ + "\x36\x37\x38\x39\x3a" /* 50 */ \ + "\x3b\x3c\x3d\xff\xff" /* 55 */ \ + "\xff\xff\xff\xff\xff" /* 60 */ \ + "\x00\x01\x02\x03\x04" /* 65 A */ \ + "\x05\x06\x07\x08\x09" /* 70 */ \ + "\x0a\x0b\x0c\x0d\x0e" /* 75 */ \ + "\x0f\x10\x11\x12\x13" /* 80 */ \ + "\x14\x15\x16\x17\x18" /* 85 */ \ + "\x19\xff\xff\xff\xff" /* 90 */ \ + "\x3f\xff\x1a\x1b\x1c" /* 95 */ \ + "\x1d\x1e\x1f\x20\x21" /* 100 */ \ + "\x22\x23\x24\x25\x26" /* 105 */ \ + "\x27\x28\x29\x2a\x2b" /* 110 */ \ + "\x2c\x2d\x2e\x2f\x30" /* 115 */ \ + "\x31\x32\x33\xff\xff" /* 120 */ \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 125 */ \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 155 */ \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 185 */ \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 215 */ \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \ + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" /* 245 */ +}; + + From 8b9b68b640986c996ed138ed5f32e3a5820bb503 Mon Sep 17 00:00:00 2001 From: Paul Wayper Date: Sun, 25 Oct 2015 11:38:10 +1100 Subject: [PATCH 2/2] Actually provide a different structure name (oops). --- ccan/base64/base64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccan/base64/base64.c b/ccan/base64/base64.c index c26e9fb56..a07967045 100644 --- a/ccan/base64/base64.c +++ b/ccan/base64/base64.c @@ -254,9 +254,9 @@ static const base64_maps_t base64_maps_rfc4648 = { }; /** - * base64url_maps_rfc4648 - rfc4648 'base64url' map with -_ rather than +/ + * base64_maps_rfc4648_urlsafe - rfc4648 'base64url' map with -_ rather than +/ */ -static const base64_maps_t base64_maps_rfc4648 = { +static const base64_maps_t base64_maps_rfc4648_urlsafe = { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", "\xff\xff\xff\xff\xff" /* 0 */ \