mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 08:43:58 +00:00
deprecate cuchar, don't redefine it (#18505)
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
|
||||
- Deprecated `std/mersenne`
|
||||
|
||||
- `cuchar` now aliases `uint8` instead of `char`
|
||||
- `cuchar` is now deprecated as it aliased `char` where arguably it should have aliased `uint8`.
|
||||
Please use `char` or `uint8` instead.
|
||||
|
||||
- `repr` now doesn't insert trailing newline; previous behavior was very inconsistent,
|
||||
see #16034. Use `-d:nimLegacyReprWithNewline` for previous behavior.
|
||||
|
||||
@@ -47,7 +47,7 @@ type
|
||||
d_ino*: Ino
|
||||
d_off*: Off
|
||||
d_reclen*: cushort
|
||||
d_type*: int8 # cuchar really!
|
||||
d_type*: int8 # uint8 really!
|
||||
d_name*: array[256, cchar]
|
||||
|
||||
Tflock* {.importc: "struct flock", final, pure,
|
||||
|
||||
@@ -33,7 +33,7 @@ type
|
||||
Dirent* {.importc: "struct dirent",
|
||||
header: "<dirent.h>", final, pure.} = object ## dirent_t struct
|
||||
d_ino*: Ino
|
||||
d_type*: int8 # cuchar really!
|
||||
d_type*: int8 # uint8 really!
|
||||
d_name*: array[256, cchar]
|
||||
|
||||
Tflock* {.importc: "struct flock", final, pure,
|
||||
@@ -347,20 +347,20 @@ type
|
||||
|
||||
SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
|
||||
pure, final.} = object ## struct sockaddr
|
||||
sa_len: cuchar
|
||||
sa_len: uint8
|
||||
sa_family*: TSa_Family ## Address family.
|
||||
sa_data*: array[14, char] ## Socket address (variable-length data).
|
||||
|
||||
Sockaddr_storage* {.importc: "struct sockaddr_storage",
|
||||
header: "<sys/socket.h>",
|
||||
pure, final.} = object ## struct sockaddr_storage
|
||||
ss_len: cuchar
|
||||
ss_len: uint8
|
||||
ss_family*: TSa_Family ## Address family.
|
||||
ss_padding1: array[64 - sizeof(cuchar) - sizeof(cshort), char]
|
||||
ss_padding1: array[64 - sizeof(uint8) - sizeof(cshort), char]
|
||||
ss_align: clonglong
|
||||
ss_padding2: array[
|
||||
128 - sizeof(cuchar) - sizeof(cshort) -
|
||||
(64 - sizeof(cuchar) - sizeof(cshort)) - 64, char]
|
||||
128 - sizeof(uint8) - sizeof(cshort) -
|
||||
(64 - sizeof(uint8) - sizeof(cshort)) - 64, char]
|
||||
|
||||
Tif_nameindex* {.importc: "struct if_nameindex", final,
|
||||
pure, header: "<net/if.h>".} = object ## struct if_nameindex
|
||||
|
||||
@@ -450,15 +450,15 @@ when useGCC_builtins:
|
||||
|
||||
elif useVCC_builtins:
|
||||
# Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1).
|
||||
func bitScanReverse(index: ptr culong, mask: culong): cuchar {.
|
||||
func bitScanReverse(index: ptr culong, mask: culong): uint8 {.
|
||||
importc: "_BitScanReverse", header: "<intrin.h>".}
|
||||
func bitScanReverse64(index: ptr culong, mask: uint64): cuchar {.
|
||||
func bitScanReverse64(index: ptr culong, mask: uint64): uint8 {.
|
||||
importc: "_BitScanReverse64", header: "<intrin.h>".}
|
||||
|
||||
# Search the mask data from least significant bit (LSB) to the most significant bit (MSB) for a set bit (1).
|
||||
func bitScanForward(index: ptr culong, mask: culong): cuchar {.
|
||||
func bitScanForward(index: ptr culong, mask: culong): uint8 {.
|
||||
importc: "_BitScanForward", header: "<intrin.h>".}
|
||||
func bitScanForward64(index: ptr culong, mask: uint64): cuchar {.
|
||||
func bitScanForward64(index: ptr culong, mask: uint64): uint8 {.
|
||||
importc: "_BitScanForward64", header: "<intrin.h>".}
|
||||
|
||||
template vcc_scan_impl(fnc: untyped; v: untyped): int =
|
||||
@@ -468,15 +468,15 @@ elif useVCC_builtins:
|
||||
|
||||
elif useICC_builtins:
|
||||
# Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined.
|
||||
func bitScanForward(p: ptr uint32, b: uint32): cuchar {.
|
||||
func bitScanForward(p: ptr uint32, b: uint32): uint8 {.
|
||||
importc: "_BitScanForward", header: "<immintrin.h>".}
|
||||
func bitScanForward64(p: ptr uint32, b: uint64): cuchar {.
|
||||
func bitScanForward64(p: ptr uint32, b: uint64): uint8 {.
|
||||
importc: "_BitScanForward64", header: "<immintrin.h>".}
|
||||
|
||||
# Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
|
||||
func bitScanReverse(p: ptr uint32, b: uint32): cuchar {.
|
||||
func bitScanReverse(p: ptr uint32, b: uint32): uint8 {.
|
||||
importc: "_BitScanReverse", header: "<immintrin.h>".}
|
||||
func bitScanReverse64(p: ptr uint32, b: uint64): cuchar {.
|
||||
func bitScanReverse64(p: ptr uint32, b: uint64): uint8 {.
|
||||
importc: "_BitScanReverse64", header: "<immintrin.h>".}
|
||||
|
||||
template icc_scan_impl(fnc: untyped; v: untyped): int =
|
||||
@@ -664,7 +664,7 @@ when useBuiltinsRotate:
|
||||
when defined(gcc):
|
||||
# GCC was tested until version 4.8.1 and intrinsics were present. Not tested
|
||||
# in previous versions.
|
||||
func builtin_rotl8(value: cuchar, shift: cint): cuchar
|
||||
func builtin_rotl8(value: uint8, shift: cint): uint8
|
||||
{.importc: "__rolb", header: "<x86intrin.h>".}
|
||||
func builtin_rotl16(value: cushort, shift: cint): cushort
|
||||
{.importc: "__rolw", header: "<x86intrin.h>".}
|
||||
@@ -674,7 +674,7 @@ when useBuiltinsRotate:
|
||||
func builtin_rotl64(value: culonglong, shift: cint): culonglong
|
||||
{.importc: "__rolq", header: "<x86intrin.h>".}
|
||||
|
||||
func builtin_rotr8(value: cuchar, shift: cint): cuchar
|
||||
func builtin_rotr8(value: uint8, shift: cint): uint8
|
||||
{.importc: "__rorb", header: "<x86intrin.h>".}
|
||||
func builtin_rotr16(value: cushort, shift: cint): cushort
|
||||
{.importc: "__rorw", header: "<x86intrin.h>".}
|
||||
@@ -690,7 +690,7 @@ when useBuiltinsRotate:
|
||||
# https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#non-comprehensive-list-of-changes-in-this-release
|
||||
# https://releases.llvm.org/8.0.0/tools/clang/docs/LanguageExtensions.html#builtin-rotateleft
|
||||
# source for correct declarations: https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def
|
||||
func builtin_rotl8(value: cuchar, shift: cuchar): cuchar
|
||||
func builtin_rotl8(value: uint8, shift: uint8): uint8
|
||||
{.importc: "__builtin_rotateleft8", nodecl.}
|
||||
func builtin_rotl16(value: cushort, shift: cushort): cushort
|
||||
{.importc: "__builtin_rotateleft16", nodecl.}
|
||||
@@ -700,7 +700,7 @@ when useBuiltinsRotate:
|
||||
func builtin_rotl64(value: culonglong, shift: culonglong): culonglong
|
||||
{.importc: "__builtin_rotateleft64", nodecl.}
|
||||
|
||||
func builtin_rotr8(value: cuchar, shift: cuchar): cuchar
|
||||
func builtin_rotr8(value: uint8, shift: uint8): uint8
|
||||
{.importc: "__builtin_rotateright8", nodecl.}
|
||||
func builtin_rotr16(value: cushort, shift: cushort): cushort
|
||||
{.importc: "__builtin_rotateright16", nodecl.}
|
||||
@@ -716,9 +716,9 @@ when useBuiltinsRotate:
|
||||
# https://docs.microsoft.com/en-us/cpp/intrinsics/rotl8-rotl16?view=msvc-160
|
||||
# https://docs.microsoft.com/en-us/cpp/intrinsics/rotr8-rotr16?view=msvc-160
|
||||
# https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rotl-rotl64-rotr-rotr64?view=msvc-160
|
||||
func builtin_rotl8(value: cuchar, shift: cuchar): cuchar
|
||||
func builtin_rotl8(value: uint8, shift: uint8): uint8
|
||||
{.importc: "_rotl8", header: "<intrin.h>".}
|
||||
func builtin_rotl16(value: cushort, shift: cuchar): cushort
|
||||
func builtin_rotl16(value: cushort, shift: uint8): cushort
|
||||
{.importc: "_rotl16", header: "<intrin.h>".}
|
||||
func builtin_rotl32(value: cuint, shift: cint): cuint
|
||||
{.importc: "_rotl", header: "<stdlib.h>".}
|
||||
@@ -726,9 +726,9 @@ when useBuiltinsRotate:
|
||||
func builtin_rotl64(value: culonglong, shift: cint): culonglong
|
||||
{.importc: "_rotl64", header: "<stdlib.h>".}
|
||||
|
||||
func builtin_rotr8(value: cuchar, shift: cuchar): cuchar
|
||||
func builtin_rotr8(value: uint8, shift: uint8): uint8
|
||||
{.importc: "_rotr8", header: "<intrin.h>".}
|
||||
func builtin_rotr16(value: cushort, shift: cuchar): cushort
|
||||
func builtin_rotr16(value: cushort, shift: uint8): cushort
|
||||
{.importc: "_rotr16", header: "<intrin.h>".}
|
||||
func builtin_rotr32(value: cuint, shift: cint): cuint
|
||||
{.importc: "_rotr", header: "<stdlib.h>".}
|
||||
@@ -738,7 +738,7 @@ when useBuiltinsRotate:
|
||||
elif defined(icl):
|
||||
# Tested on Intel(R) C++ Intel(R) 64 Compiler Classic Version 2021.1.2 Build
|
||||
# 20201208_000000 x64 and x86. Not tested in previous versions.
|
||||
func builtin_rotl8(value: cuchar, shift: cint): cuchar
|
||||
func builtin_rotl8(value: uint8, shift: cint): uint8
|
||||
{.importc: "__rolb", header: "<immintrin.h>".}
|
||||
func builtin_rotl16(value: cushort, shift: cint): cushort
|
||||
{.importc: "__rolw", header: "<immintrin.h>".}
|
||||
@@ -748,7 +748,7 @@ when useBuiltinsRotate:
|
||||
func builtin_rotl64(value: culonglong, shift: cint): culonglong
|
||||
{.importc: "__rolq", header: "<immintrin.h>".}
|
||||
|
||||
func builtin_rotr8(value: cuchar, shift: cint): cuchar
|
||||
func builtin_rotr8(value: uint8, shift: cint): uint8
|
||||
{.importc: "__rorb", header: "<immintrin.h>".}
|
||||
func builtin_rotr16(value: cushort, shift: cint): cushort
|
||||
{.importc: "__rorw", header: "<immintrin.h>".}
|
||||
@@ -777,7 +777,7 @@ func shiftTypeTo(size: static int, shift: int): auto {.inline.} =
|
||||
when (defined(vcc) and (size in [4, 8])) or defined(gcc) or defined(icl):
|
||||
cint(shift)
|
||||
elif (defined(vcc) and (size in [1, 2])) or (defined(clang) and size == 1):
|
||||
cuchar(shift)
|
||||
uint8(shift)
|
||||
elif defined(clang):
|
||||
when size == 2:
|
||||
cushort(shift)
|
||||
@@ -802,7 +802,7 @@ func rotateLeftBits*[T: SomeUnsignedInt](value: T, shift: range[0..(sizeof(T) *
|
||||
when useBuiltinsRotate:
|
||||
const size = sizeof(T)
|
||||
when size == 1:
|
||||
builtin_rotl8(value.cuchar, shiftTypeTo(size, shift)).T
|
||||
builtin_rotl8(value.uint8, shiftTypeTo(size, shift)).T
|
||||
elif size == 2:
|
||||
builtin_rotl16(value.cushort, shiftTypeTo(size, shift)).T
|
||||
elif size == 4:
|
||||
@@ -830,7 +830,7 @@ func rotateRightBits*[T: SomeUnsignedInt](value: T, shift: range[0..(sizeof(T) *
|
||||
when useBuiltinsRotate:
|
||||
const size = sizeof(T)
|
||||
when size == 1:
|
||||
builtin_rotr8(value.cuchar, shiftTypeTo(size, shift)).T
|
||||
builtin_rotr8(value.uint8, shiftTypeTo(size, shift)).T
|
||||
elif size == 2:
|
||||
builtin_rotr16(value.cushort, shiftTypeTo(size, shift)).T
|
||||
elif size == 4:
|
||||
|
||||
@@ -503,7 +503,7 @@ when defineSsl:
|
||||
## Retrieve the ssl pointer of `socket`.
|
||||
## Useful for interfacing with `openssl`.
|
||||
self.sslHandle
|
||||
|
||||
|
||||
proc raiseSSLError*(s = "") =
|
||||
## Raises a new SSL error.
|
||||
if s != "":
|
||||
@@ -688,7 +688,7 @@ when defineSsl:
|
||||
return ctx.getExtraInternal().clientGetPskFunc
|
||||
|
||||
proc pskClientCallback(ssl: SslPtr; hint: cstring; identity: cstring;
|
||||
max_identity_len: cuint; psk: ptr cuchar;
|
||||
max_identity_len: cuint; psk: ptr uint8;
|
||||
max_psk_len: cuint): cuint {.cdecl.} =
|
||||
let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
|
||||
let hintString = if hint == nil: "" else: $hint
|
||||
@@ -714,7 +714,7 @@ when defineSsl:
|
||||
proc serverGetPskFunc*(ctx: SslContext): SslServerGetPskFunc =
|
||||
return ctx.getExtraInternal().serverGetPskFunc
|
||||
|
||||
proc pskServerCallback(ssl: SslCtx; identity: cstring; psk: ptr cuchar;
|
||||
proc pskServerCallback(ssl: SslCtx; identity: cstring; psk: ptr uint8;
|
||||
max_psk_len: cint): cuint {.cdecl.} =
|
||||
let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
|
||||
let pskString = (ctx.serverGetPskFunc)($identity)
|
||||
|
||||
@@ -761,7 +761,7 @@ template styledWriteLine*(f: File, args: varargs[untyped]) =
|
||||
runnableExamples:
|
||||
proc error(msg: string) =
|
||||
styledWriteLine(stderr, fgRed, "Error: ", resetStyle, msg)
|
||||
|
||||
|
||||
styledWrite(f, args)
|
||||
write(f, "\n")
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ elif defined(windows):
|
||||
type
|
||||
PVOID = pointer
|
||||
BCRYPT_ALG_HANDLE = PVOID
|
||||
PUCHAR = ptr cuchar
|
||||
PUCHAR = ptr uint8
|
||||
NTSTATUS = clong
|
||||
ULONG = culong
|
||||
|
||||
|
||||
@@ -1427,8 +1427,8 @@ type # these work for most platforms:
|
||||
## This is the same as the type `long double` in *C*.
|
||||
## This C type is not supported by Nim's code generator.
|
||||
|
||||
cuchar* {.importc: "unsigned char", nodecl.} = uint8
|
||||
## This is the same as the type `unsigned char` in *C*.
|
||||
cuchar* {.importc: "unsigned char", nodecl, deprecated: "use `char` or `uint8` instead".} = char
|
||||
## Deprecated: Use `uint8` instead.
|
||||
cushort* {.importc: "unsigned short", nodecl.} = uint16
|
||||
## This is the same as the type `unsigned short` in *C*.
|
||||
cuint* {.importc: "unsigned int", nodecl.} = uint32
|
||||
|
||||
@@ -42,7 +42,7 @@ type
|
||||
PULONG_PTR* = ptr uint
|
||||
HDC* = Handle
|
||||
HGLRC* = Handle
|
||||
BYTE* = cuchar
|
||||
BYTE* = uint8
|
||||
|
||||
SECURITY_ATTRIBUTES* {.final, pure.} = object
|
||||
nLength*: int32
|
||||
@@ -717,7 +717,7 @@ const
|
||||
FILE_WRITE_DATA* = 0x00000002 # file & pipe
|
||||
|
||||
# Error Constants
|
||||
const
|
||||
const
|
||||
ERROR_FILE_NOT_FOUND* = 2 ## https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
|
||||
ERROR_PATH_NOT_FOUND* = 3
|
||||
ERROR_ACCESS_DENIED* = 5
|
||||
|
||||
@@ -520,16 +520,16 @@ proc OPENSSL_sk_num*(stack: PSTACK): int {.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc OPENSSL_sk_value*(stack: PSTACK, index: int): pointer {.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
|
||||
proc d2i_X509*(px: ptr PX509, i: ptr ptr cuchar, len: cint): PX509 {.cdecl,
|
||||
proc d2i_X509*(px: ptr PX509, i: ptr ptr uint8, len: cint): PX509 {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc i2d_X509*(cert: PX509; o: ptr ptr cuchar): cint {.cdecl,
|
||||
proc i2d_X509*(cert: PX509; o: ptr ptr uint8): cint {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc d2i_X509*(b: string): PX509 =
|
||||
## decode DER/BER bytestring into X.509 certificate struct
|
||||
var bb = b.cstring
|
||||
let i = cast[ptr ptr cuchar](addr bb)
|
||||
let i = cast[ptr ptr uint8](addr bb)
|
||||
let ret = d2i_X509(addr result, i, b.len.cint)
|
||||
if ret.isNil:
|
||||
raise newException(Exception, "X.509 certificate decoding failed")
|
||||
@@ -539,7 +539,7 @@ proc i2d_X509*(cert: PX509): string =
|
||||
let encoded_length = i2d_X509(cert, nil)
|
||||
result = newString(encoded_length)
|
||||
var q = result.cstring
|
||||
let o = cast[ptr ptr cuchar](addr q)
|
||||
let o = cast[ptr ptr uint8](addr q)
|
||||
let length = i2d_X509(cert, o)
|
||||
if length.int <= 0:
|
||||
raise newException(Exception, "X.509 certificate encoding failed")
|
||||
@@ -599,11 +599,11 @@ proc SSL_CTX_set_tlsext_servername_arg*(ctx: SslCtx, arg: pointer): int =
|
||||
|
||||
type
|
||||
PskClientCallback* = proc (ssl: SslPtr;
|
||||
hint: cstring; identity: cstring; max_identity_len: cuint; psk: ptr cuchar;
|
||||
hint: cstring; identity: cstring; max_identity_len: cuint; psk: ptr uint8;
|
||||
max_psk_len: cuint): cuint {.cdecl.}
|
||||
|
||||
PskServerCallback* = proc (ssl: SslPtr;
|
||||
identity: cstring; psk: ptr cuchar; max_psk_len: cint): cuint {.cdecl.}
|
||||
identity: cstring; psk: ptr uint8; max_psk_len: cint): cuint {.cdecl.}
|
||||
|
||||
proc SSL_CTX_set_psk_client_callback*(ctx: SslCtx; callback: PskClientCallback) {.cdecl, dynlib: DLLSSLName, importc.}
|
||||
## Set callback called when OpenSSL needs PSK (for client).
|
||||
@@ -672,13 +672,13 @@ proc PEM_read_bio_RSAPublicKey*(bp: BIO, x: ptr PRSA, cb: pem_password_cb, u: po
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc PEM_read_bio_RSAPrivateKey*(bp: BIO, x: ptr PRSA, cb: pem_password_cb, u: pointer): PRSA {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc RSA_private_encrypt*(flen: cint, fr: ptr cuchar, to: ptr cuchar, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
proc RSA_private_encrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc RSA_public_encrypt*(flen: cint, fr: ptr cuchar, to: ptr cuchar, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
proc RSA_public_encrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc RSA_private_decrypt*(flen: cint, fr: ptr cuchar, to: ptr cuchar, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
proc RSA_private_decrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc RSA_public_decrypt*(flen: cint, fr: ptr cuchar, to: ptr cuchar, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
proc RSA_public_decrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc RSA_free*(rsa: PRSA) {.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc RSA_size*(rsa: PRSA): cint {.cdecl, dynlib: DLLUtilName, importc.}
|
||||
@@ -744,8 +744,8 @@ type
|
||||
proc md5_Init*(c: var MD5_CTX): cint{.importc: "MD5_Init".}
|
||||
proc md5_Update*(c: var MD5_CTX; data: pointer; len: csize_t): cint{.importc: "MD5_Update".}
|
||||
proc md5_Final*(md: cstring; c: var MD5_CTX): cint{.importc: "MD5_Final".}
|
||||
proc md5*(d: ptr cuchar; n: csize_t; md: ptr cuchar): ptr cuchar{.importc: "MD5".}
|
||||
proc md5_Transform*(c: var MD5_CTX; b: ptr cuchar){.importc: "MD5_Transform".}
|
||||
proc md5*(d: ptr uint8; n: csize_t; md: ptr uint8): ptr uint8{.importc: "MD5".}
|
||||
proc md5_Transform*(c: var MD5_CTX; b: ptr uint8){.importc: "MD5_Transform".}
|
||||
{.pop.}
|
||||
|
||||
from strutils import toHex, toLowerAscii
|
||||
|
||||
@@ -12,8 +12,8 @@ proc rsaPublicEncrypt(fr: string): string =
|
||||
doAssert rsa != nil
|
||||
doAssert BIO_free(bio) >= 0
|
||||
result = newString(RSA_size(rsa))
|
||||
let frdata = cast[ptr cuchar](fr.cstring)
|
||||
var todata = cast[ptr cuchar](result.cstring)
|
||||
let frdata = cast[ptr uint8](fr.cstring)
|
||||
var todata = cast[ptr uint8](result.cstring)
|
||||
doAssert RSA_public_encrypt(fr.len.cint, frdata, todata, rsa, RSA_PKCS1_PADDING) != -1
|
||||
RSA_free(rsa)
|
||||
|
||||
@@ -26,8 +26,8 @@ proc rasPrivateDecrypt(fr: string): string =
|
||||
doAssert BIO_free(bio) >= 0
|
||||
let rsaLen = RSA_size(rsa)
|
||||
result = newString(rsaLen)
|
||||
let frdata = cast[ptr cuchar](fr.cstring)
|
||||
var todata = cast[ptr cuchar](result.cstring)
|
||||
let frdata = cast[ptr uint8](fr.cstring)
|
||||
var todata = cast[ptr uint8](result.cstring)
|
||||
let lenOrig = RSA_private_decrypt(rsaLen, frdata, todata, rsa, RSA_PKCS1_PADDING)
|
||||
doAssert lenOrig >= 0 and lenOrig < result.len
|
||||
doAssert result[lenOrig] == '\0'
|
||||
|
||||
Reference in New Issue
Block a user