' Base64/Base64URL constants plus WinCrypt conversion declarations.
#IF NOT %DEF(PBX_BASE64URL_PBI)
#DEFINE PBX_BASE64URL_PBI
#INCLUDE ONCE "Legacy/Platform/win_types.inc"

%EQUATE `CRYPT_STRING_BASE64HEADER = &H00000000
%EQUATE `CRYPT_STRING_BASE64 = &H00000001
%EQUATE `CRYPT_STRING_BINARY = &H00000002
%EQUATE `CRYPT_STRING_BASE64REQUESTHEADER = &H00000003
%EQUATE `CRYPT_STRING_HEX = &H00000004
%EQUATE `CRYPT_STRING_HEXASCII = &H00000005
%EQUATE `CRYPT_STRING_BASE64_ANY = &H00000006
%EQUATE `CRYPT_STRING_ANY = &H00000007
%EQUATE `CRYPT_STRING_HEX_ANY = &H00000008
%EQUATE `CRYPT_STRING_BASE64X509CRLHEADER = &H00000009
%EQUATE `CRYPT_STRING_HEXADDR = &H0000000A
%EQUATE `CRYPT_STRING_HEXASCIIADDR = &H0000000B
%EQUATE `CRYPT_STRING_HEXRAW = &H0000000C
%EQUATE `CRYPT_STRING_NOCRLF = &H40000000
%EQUATE `CRYPT_STRING_NOCR = &H80000000
%EQUATE `BASE64URL_FLAG_NO_PADDING = &H00000001
%EQUATE `BASE64URL_FLAG_STRICT = &H00000002

DECLARE FUNCTION CryptBinaryToStringA LIB "crypt32.dll" ALIAS "CryptBinaryToStringA" (BYVAL pbBinary AS QUAD, BYVAL cbBinary AS DWORD, BYVAL dwFlags AS DWORD, BYVAL pszString AS QUAD, BYVAL pcchString AS QUAD) AS LONG
DECLARE FUNCTION CryptBinaryToStringW LIB "crypt32.dll" ALIAS "CryptBinaryToStringW" (BYVAL pbBinary AS QUAD, BYVAL cbBinary AS DWORD, BYVAL dwFlags AS DWORD, BYVAL pszString AS QUAD, BYVAL pcchString AS QUAD) AS LONG
DECLARE FUNCTION CryptStringToBinaryA LIB "crypt32.dll" ALIAS "CryptStringToBinaryA" (BYVAL pszString AS ASCIIZ PTR, BYVAL cchString AS DWORD, BYVAL dwFlags AS DWORD, BYVAL pbBinary AS QUAD, BYVAL pcbBinary AS QUAD, BYVAL pdwSkip AS QUAD, BYVAL pdwFlags AS QUAD) AS LONG
DECLARE FUNCTION CryptStringToBinaryW LIB "crypt32.dll" ALIAS "CryptStringToBinaryW" (BYVAL pszString AS WSTRING, BYVAL cchString AS DWORD, BYVAL dwFlags AS DWORD, BYVAL pbBinary AS QUAD, BYVAL pcbBinary AS QUAD, BYVAL pdwSkip AS QUAD, BYVAL pdwFlags AS QUAD) AS LONG
DECLARE FUNCTION PBXBase64Url_Encode LIB "pbxapi64.dll" ALIAS "PBXBase64Url_Encode" (BYVAL pData AS QUAD, BYVAL cbData AS QUAD, BYVAL flags AS DWORD, BYVAL ppText AS QUAD, BYVAL pcbText AS QUAD) AS LONG
DECLARE FUNCTION PBXBase64Url_Decode LIB "pbxapi64.dll" ALIAS "PBXBase64Url_Decode" (BYVAL pText AS QUAD, BYVAL cbText AS QUAD, BYVAL flags AS DWORD, BYVAL ppData AS QUAD, BYVAL pcbData AS QUAD) AS LONG

#ENDIF
