-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the libb64 support from debian package maintainer
Submitted-by: Thorsten Alteholz <[email protected]> Signed-off-by: Ben Collins <[email protected]>
- Loading branch information
1 parent
7e35485
commit 9a171e5
Showing
7 changed files
with
65 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* Copyright (C) 2019 Thorsten Alteholz <[email protected]> | ||
Copyright (C) 2024 Ben Collins <[email protected]> | ||
This file is part of the JWT C Library | ||
SPDX-License-Identifier: MPL-2.0 | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include <string.h> | ||
|
||
#include <b64/cencode.h> | ||
#include <b64/cdecode.h> | ||
|
||
int jwt_Base64encode(char *coded_dst, const char *plain_src, int len_plain_src) | ||
{ | ||
base64_encodestate state; | ||
int count, i, len; | ||
char *rp = coded_dst, *wp = coded_dst; | ||
|
||
base64_init_encodestate(&state); | ||
count = base64_encode_block(plain_src, len_plain_src, coded_dst, &state); | ||
count += base64_encode_blockend(coded_dst + count, &state); | ||
|
||
/* | ||
* the b64 library might insert \n after some chars, | ||
* these must be removed again | ||
* (at least in order to pass the tests) | ||
*/ | ||
len = count; | ||
for (i = 0; i < len; i++) { | ||
if (*rp != '\n') | ||
*wp++ = *rp; | ||
else | ||
count--; | ||
rp++; | ||
} | ||
coded_dst[count] = 0; | ||
|
||
return count; | ||
} | ||
|
||
int jwt_Base64decode(char *plain_dst, const char *coded_src) | ||
{ | ||
base64_decodestate state; | ||
int count = 0; | ||
|
||
base64_init_decodestate(&state); | ||
count = base64_decode_block(coded_src, strlen(coded_src), plain_dst, &state); | ||
|
||
return count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters