mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-24 01:06:33 +08:00
update base58
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/base58.h>
|
||||
|
||||
static const int8_t b58digits_map[] = {
|
||||
@@ -97,9 +97,11 @@ bool base58_decode(const char *b58, size_t b58sz, void *bin, size_t *binszp)
|
||||
|
||||
for ( ; i < b58sz; ++i)
|
||||
{
|
||||
if (b58u[i] & 0x80)
|
||||
if (b58u[i] & 0x80) {
|
||||
// High-bit set on invalid digit
|
||||
BASE58err(BASE58_F_BASE58_DECODE, BASE58_R_HIGHBIT_SET_ON_INVALID_DIGIT);
|
||||
return false;
|
||||
}
|
||||
if (b58digits_map[b58u[i]] == -1)
|
||||
// Invalid base58 digit
|
||||
return false;
|
||||
|
||||
44
crypto/base58/base58_err.c
Normal file
44
crypto/base58/base58_err.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/base58.h>
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_BASE58,func,0)
|
||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_BASE58,0,reason)
|
||||
|
||||
static ERR_STRING_DATA BASE58_str_functs[] = {
|
||||
{ERR_FUNC(BASE58_F_BASE58_DECODE), "base58_decode"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static ERR_STRING_DATA BASE58_str_reasons[] = {
|
||||
{ERR_REASON(BASE58_R_HIGHBIT_SET_ON_INVALID_DIGIT),
|
||||
"highbit set on invalid digit"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int ERR_load_BASE58_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(BASE58_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings(0, BASE58_str_functs);
|
||||
ERR_load_strings(0, BASE58_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=base58.c
|
||||
SOURCE[../../libcrypto]=base58.c base58_err.c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user