Hello,
I want to exchange messages between different users via network share and by using files.
I want to check that senders and receivers are correct.
So, sender shall have a public key with which a receiver can check a digital signature of a sender.
Then, a receiver gets a message encrypted with public key and only the receiver can open it with its private key.
So far so public-key-encryption...
Is there a simple example available how I can achieve this with PureBasic?
It should be easy done with PureBasic; I have problems understanding how a digital signature from sender can be checked by receiver with public key (if done with public key?).
Thanks in advance for any hints!
Public private key for file exchange
Re: Public private key for file exchange
use crypotosyspki
http://www.cryptosys.net/pki/index.html
http://www.cryptosys.net/pki/index.html
Code: Select all
#DICRPKI_H_ = 1
; GENERAL CONSTANTS
#PKI_DIR_ENCRYPT = 1
; Synonyms for direction
#PKI_DIR_DECRYPT = 0
#ENCRYPT = 1
; Maximum number of bytes in hash digest byte array
#DECRYPT = 0
#PKI_MAX_HASH_BYTES = 64
#PKI_SHA1_BYTES = 20
#PKI_SHA224_BYTES = 28
#PKI_SHA256_BYTES = 32
#PKI_SHA384_BYTES = 48
#PKI_SHA512_BYTES = 64
#PKI_MD5_BYTES = 16
#PKI_MD2_BYTES = 16
#PKI_RMD160_BYTES = 20
#PKI_BTC160_BYTES = 20
; Maximum number of hex characters in hash digest (excl null)
#PKI_MAX_HASH_CHARS = (2*#PKI_MAX_HASH_BYTES)
#PKI_SHA1_CHARS = (2*#PKI_SHA1_BYTES)
#PKI_SHA224_CHARS = (2*#PKI_SHA224_BYTES)
#PKI_SHA256_CHARS = (2*#PKI_SHA256_BYTES)
#PKI_SHA384_CHARS = (2*#PKI_SHA384_BYTES)
#PKI_SHA512_CHARS = (2*#PKI_SHA512_BYTES)
#PKI_MD5_CHARS = (2*#PKI_MD5_BYTES)
#PKI_MD2_CHARS = (2*#PKI_MD2_BYTES)
#PKI_RMD160_CHARS = (2*#PKI_RMD160_BYTES)
#PKI_BTC160_CHARS = (2*#PKI_BTC160_BYTES)
; Synonym retained for backwards compatibility
; Encryption block sizes in bytes
#PKI_MAX_HASH_LEN = #PKI_MAX_HASH_CHARS
#PKI_BLK_TDEA_BYTES = 8
; Key size in bytes
#PKI_BLK_AES_BYTES = 16
#PKI_KEYSIZE_TDEA_BYTES = 24
; Required size for RNG seed file
#PKI_KEYSIZE_MAX_BYTES = 32
#PKI_RNG_SEED_BYTES = 64
; OPTIONS
#PKI_DEFAULT = 0
; Signature algorithms
#PKI_SIG_SHA1RSA = 0
#PKI_SIG_MD5RSA = 1
#PKI_SIG_MD2RSA = 2
#PKI_SIG_SHA256RSA = 3
#PKI_SIG_SHA384RSA = 4
#PKI_SIG_SHA512RSA = 5
#PKI_SIG_SHA224RSA = 6
; New in [v11.0] ...
#PKI_SIG_ECDSA_SHA1 = $10
#PKI_SIG_ECDSA_SHA224 = $20
#PKI_SIG_ECDSA_SHA256 = $30
#PKI_SIG_ECDSA_SHA384 = $40
#PKI_SIG_ECDSA_SHA512 = $50
; PKCS#5 Password-based encryption algorithms
#PKI_PBE_SHA_3DES = 0 ; Default
; Added in [v11.0] As simpler alternative To PKI_PBE_PBES2 + PKI_BC
#PKI_PBE_PBKDF2_DESEDE3 = $1010
#PKI_PBE_PBKDF2_AES128 = $1020
#PKI_PBE_PBKDF2_AES192 = $1030
#PKI_PBE_PBKDF2_AES256 = $1040
; --0x1820L Reserved For PKI_PBE_SCRYPT_AES128
; --0x1840L Reserved For PKI_PBE_SCRYPT_AES256
; These Next 3 changed in [v11.0] (by adding 0x8000000)
#PKI_PBE_MD5_DES = $8000001 ; [Not recommended For new implementations]
#PKI_PBE_MD2_DES = $8000002 ; [Not recommended For new implementations]
#PKI_PBE_SHA_DES = $8000003 ; [Not recommended For new implementations]
; Synonym retained For backwards compatibility
#PKI_PBES2_3DES = #PKI_PBE_PBKDF2_DESEDE3
; Older alternative To specify PBES2 PBKDF2
#PKI_PBE_PBES2 = $1000 ; Add PKI_BC_* option To specify encryption alg
; Message digest hash algorithms
#PKI_HASH_SHA1 = 0
#PKI_HASH_MD5 = 1
#PKI_HASH_MD2 = 2
#PKI_HASH_SHA256 = 3
#PKI_HASH_SHA384 = 4
#PKI_HASH_SHA512 = 5
#PKI_HASH_SHA224 = 6
#PKI_HASH_RMD160 = 7 ; RIPEMD160 - New in [v11.0]
#PKI_HASH_BTC160 = 8 ; BITCOIN160 - New in [v11.0]
#PKI_HASH_MODE_TEXT = $10000
#PKI_HASH_DOUBLE = $20000 ; New in [v11.0]
; nFermatExp values for RSA exponent
#PKI_RSAEXP_EQ_3 = 0
#PKI_RSAEXP_EQ_5 = 1
#PKI_RSAEXP_EQ_17 = 2
#PKI_RSAEXP_EQ_257 = 3
#PKI_RSAEXP_EQ_65537 = 4
; Return values for RSA_CheckKey
#PKI_VALID_PUBLICKEY = 1
#PKI_VALID_PRIVATEKEY = 0
; BIT FLAGS
; RSA key generation
; PKI_KEY_NODELAY removed in v3.3
#PKI_KEYGEN_INDICATE = $1000000
#PKI_KEY_FORMAT_PEM = $10000
#PKI_KEY_FORMAT_SSL = $20000
#PKI_KEY_TYPE_PKCS8 = $40000 ; New in [v11.0]
#PKI_PFX_PLAIN_CERT = $2000000
#PKI_PFX_CLONE_KEY = $4000000
#PKI_PFX_ALT_FORMAT = $100000
#PKI_PFX_P7CHAIN = $0400 ; New in [v10.0]
#PKI_CMS_FORMAT_BASE64 = $10000
#PKI_CMS_EXCLUDE_CERTS = $0100
#PKI_CMS_EXCLUDE_DATA = $0200
#PKI_CMS_CERTS_ONLY = $0400
#PKI_CMS_INCLUDE_ATTRS = $0800
#PKI_CMS_ADD_SIGNTIME = $1000
#PKI_CMS_ADD_SMIMECAP = $2000
#PKI_CMS_NO_INFLATE = $1000000
#PKI_CMS_NO_OUTER = $2000000
#PKI_CMS_ALT_ALGID = $4000000
#PKI_CMS_BIGFILE = $8000000
#PKI_XML_RSAKEYVALUE = $0001
#PKI_XML_EXCLPRIVATE = $0010
#PKI_XML_REQPRIVATE = $0020
#PKI_XML_HEXBINARY = $0100
#PKI_EME_DEFAULT = $00
#PKI_EME_PKCSV1_5 = $00
#PKI_EME_OAEP = $10
#PKI_EMSIG_DEFAULT = $20
#PKI_EMSIG_PKCSV1_5 = $20
#PKI_EMSIG_DIGESTONLY = $1000
#PKI_EMSIG_DIGINFO = $2000
#PKI_EMSIG_ISO9796 = $100000
; X.509 Option flags
#PKI_X509_FORMAT_PEM = $10000
#PKI_X509_FORMAT_BIN = $20000
#PKI_X509_REQ_KLUDGE = $100000
#PKI_X509_NO_TIMECHECK = $200000
#PKI_X509_LATIN1 = $400000
#PKI_X509_UTF8 = $800000
#PKI_X509_AUTHKEYID = $1000000
#PKI_X509_NO_BASIC = $2000000
#PKI_X509_CA_TRUE = $4000000
#PKI_X509_VERSION1 = $8000000
#PKI_X509_LDAP = $1000
; Flags for X.509 Key Usage
#PKI_X509_DECIMAL = $8000
#PKI_X509_KEYUSAGE_DIGITALSIGNATURE = $0001
#PKI_X509_KEYUSAGE_NONREPUDIATION = $0002
#PKI_X509_KEYUSAGE_KEYENCIPHERMENT = $0004
#PKI_X509_KEYUSAGE_DATAENCIPHERMENT = $0008
#PKI_X509_KEYUSAGE_KEYAGREEMENT = $0010
#PKI_X509_KEYUSAGE_KEYCERTSIGN = $0020
#PKI_X509_KEYUSAGE_CRLSIGN = $0040
#PKI_X509_KEYUSAGE_ENCIPHERONLY = $0080
; Specific return values
#PKI_X509_KEYUSAGE_DECIPHERONLY = $0100
#PKI_X509_EXPIRED = -1
#PKI_X509_VALID_NOW = 0
#PKI_X509_VERIFY_SUCCESS = 0
#PKI_X509_VERIFY_FAILURE = -1
#PKI_X509_REVOKED = 1
#PKI_X509_INVALID = 1
; Return values for CNV_CheckUTF
#PKI_CHRS_NOT_UTF8 = 0
#PKI_CHRS_ALL_ASCII = 1
#PKI_CHRS_ANSI8 = 2
#PKI_CHRS_MULTIBYTE = 3
; Options for CNV_ByteEncoding
#PKI_CNV_UTF8_FROM_LATIN1 = 1
#PKI_CNV_LATIN1_FROM_UTF8 = 2
; Options For CNV_Num[To/From]Bytes - new in [v11.0]
#PKI_CNV_BIG_ENDIAN = $0
#PKI_CNV_LITTLE_ENDIAN = $1
; Flags and return values for X.509 and CMS query functions
#PKI_QUERY_GETTYPE = $100000
#PKI_QUERY_NUMBER = 1
#PKI_QUERY_STRING = 2
; Options for RNG functions
#PKI_RNG_STRENGTH_112 = $00
#PKI_RNG_STRENGTH_128 = $01
; Block cipher (BC) algorithm options
#PKI_BC_TDEA = $10
#PKI_BC_3DES = $10
#PKI_BC_DESEDE3 = $10
#PKI_BC_AES128 = $20
#PKI_BC_AES192 = $30
#PKI_BC_AES256 = $40
; Block cipher mode options
#PKI_MODE_ECB = $000
#PKI_MODE_CBC = $100
#PKI_MODE_OFB = $200
#PKI_MODE_CFB = $300
#PKI_MODE_CTR = $400
; Block cipher padding options - added [v3.10]
#PKI_PAD_DEFAULT = $0
#PKI_PAD_NOPAD = $10000
#PKI_PAD_PKCS5 = $20000
#PKI_PAD_1ZERO = $30000
; Cipher file option flags
#PKI_IV_PREFIX = $1000
#PKI_PAD_LEAVE = $2000
; Key transport algorithms
; --$1000L Reserved for PKI_KT_RSAES_OEAP
#PKI_KT_RSAES_PKCS = $0000
; --$2000L Reserved for PKI_KT_RSA_KEM ;added v3.2 withdrawn v3.4
; Key derivation functions
; --$300L Reserved for PKI_KDF_KDF3
#PKI_KDF_KDF2 = $000
; ASN.1 utilities - added [v10.0]
#PKI_ASN1_NOCOMMENTS = $100000
#PKI_ASN1_ADDLEVELS = $800000
#PKI_ASN1_TYPE_MAXCHARS = 64
; SIG functions - added [v10.0]
#PKI_SIG_USEDIGEST = $1000
#PKI_SIG_DETERMINISTIC = $2000 ; Added [v11.0]
#PKI_SIG_ASN1DER = $200000 ; Added [v11.0]
; SMIME functions - added [v10.0]
#PKI_SMIME_ENCODE_BASE64 = $10000
#PKI_SMIME_ENCODE_BINARY = $20000
#PKI_SMIME_ADDX = $100000
; Encoding options - added [v11.0]
#PKI_ENCODE_HEX = $30000
#PKI_ENCODE_BASE64URL = $40000
; General
#PKI_GEN_PLATFORM = $40
#PKI_GEN_LEGACY = $8000000 ; Added [v11.0]
; __stdcall convention required for Win32/64 DLL only
Import "diCrPKI.lib"
; GENERAL FUNCTIONS
PKI_Version.l(*nReserved1.long, *nReserved2.long) As "PKI_Version"
PKI_LicenceType.l(nOptions.l) As "PKI_LicenceType"
PKI_LastError.l(*szOutput.p-ascii, nOutChars.l) As "PKI_LastError"
PKI_ErrorCode.l() As "PKI_ErrorCode"
PKI_ErrorLookup.l(*szOutput.p-ascii, nOutChars.l, nErrCode.l) As "PKI_ErrorLookup"
PKI_CompileTime.l(*szOutput.p-ascii, nOutChars.l) As "PKI_CompileTime"
PKI_ModuleName.l(*szOutput.p-ascii, nOutChars.l, nOptions.l) As "PKI_ModuleName"
PKI_PowerUpTests.l(nOptions.l) As "PKI_PowerUpTests"
; CRYPTOGRAPHIC MESSAGE SYNTAX (CMS) FUNCTIONS
CMS_MakeEnvData.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *szCertList.p-ascii, *szSeed.p-ascii, nSeedLen.l, nOptions.l) As "CMS_MakeEnvData"
CMS_MakeEnvDataFromString.l(*szFileOut.p-ascii, *szDataIn.p-ascii, *szCertList.p-ascii, *szSeed.p-ascii, nSeedLen.l, nOptions.l) As "CMS_MakeEnvDataFromString"
CMS_ReadEnvData.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *szCertFile.p-ascii, *szPrivateKey.p-ascii, nOptions.l) As "CMS_ReadEnvData"
CMS_ReadEnvDataToString.l(*szOutput.p-ascii, nOutChars.l, *szFileIn.p-ascii, *szCertFile.p-ascii, *szPrivateKey.p-ascii, nOptions.l) As "CMS_ReadEnvDataToString"
CMS_MakeSigData.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *szCertList.p-ascii, *szPrivateKey.p-ascii, nOptions.l) As "CMS_MakeSigData"
CMS_MakeSigDataFromString.l(*szFileOut.p-ascii, *szDataIn.p-ascii, *szCertList.p-ascii, *szPrivateKey.p-ascii, nOptions.l) As "CMS_MakeSigDataFromString"
CMS_MakeSigDataFromSigValue.l(*szFileOut.p-ascii, *lpSigValue.p-ascii, nSigLen.l, *lpData.p-ascii, nDataLen.l, *szCertList.p-ascii, nOptions.l) As "CMS_MakeSigDataFromSigValue"
CMS_MakeDetachedSig.l(*szFileOut.p-ascii, *szHexDigest.p-ascii, *szCertList.p-ascii, *szPrivateKey.p-ascii, nOptions.l) As "CMS_MakeDetachedSig"
CMS_ReadSigData.l(*szFileOut.p-ascii, *szFileIn.p-ascii, nOptions.l) As "CMS_ReadSigData"
CMS_ReadSigDataToString.l(*szOutput.p-ascii, nOutChars.l, *szFileIn.p-ascii, nOptions.l) As "CMS_ReadSigDataToString"
CMS_GetSigDataDigest.l(*szOutput.p-ascii, nOutChars.l, *szFileIn.p-ascii, *szCertFile.p-ascii, nOptions.l) As "CMS_GetSigDataDigest"
CMS_VerifySigData.l(*szFileIn.p-ascii, *szCertFile.p-ascii, *szHexDigest.p-ascii, nOptions.l) As "CMS_VerifySigData"
CMS_QuerySigData.l(*szOutput.p-ascii, nOutChars.l, *szFileIn.p-ascii, *szQuery.p-ascii, nOptions.l) As "CMS_QuerySigData"
CMS_QueryEnvData.l(*szOutput.p-ascii, nOutChars.l, *szFileIn.p-ascii, *szQuery.p-ascii, nOptions.l) As "CMS_QueryEnvData"
; New in v10.0
CMS_MakeComprData.l(*szFileOut.p-ascii, *szFileIn.p-ascii, nOptions.l) As "CMS_MakeComprData"
CMS_ReadComprData.l(*szFileOut.p-ascii, *szFileIn.p-ascii, nOptions.l) As "CMS_ReadComprData"
; RSA KEY FUNCTIONS
RSA_MakeKeys.l(*szPubKeyFile.p-ascii, *szEpkFile.p-ascii, nBits.l, nExpFermat.l, nTests.l, nCount.l, *szPassword.p-ascii, *lpSeed, nSeedLen.l, nOptions.l) As "RSA_MakeKeys"
RSA_ReadEncPrivateKey.l(*szOutput.p-ascii, nOutChars.l, *szEpkFile.p-ascii, *szPassword.p-ascii, nOptions.l) As "RSA_ReadEncPrivateKey"
RSA_ReadPrivateKeyInfo.l(*szOutput.p-ascii, nOutChars.l, *szKeyFile.p-ascii, nOptions.l) As "RSA_ReadPrivateKeyInfo"
RSA_GetPrivateKeyFromPFX.l(*szFileOut.p-ascii, *szPfxFile.p-ascii, nOptions.l) As "RSA_GetPrivateKeyFromPFX"
RSA_ReadPublicKey.l(*szOutput.p-ascii, nOutChars.l, *szPubKeyFile.p-ascii, nOptions.l) As "RSA_ReadPublicKey"
RSA_GetPublicKeyFromCert.l(*szOutput.p-ascii, nOutChars.l, *szCertFile.p-ascii, nOptions.l) As "RSA_GetPublicKeyFromCert"
RSA_SavePublicKey.l(*szFileOut.p-ascii, *szKeyString.p-ascii, nOptions.l) As "RSA_SavePublicKey"
RSA_SavePrivateKeyInfo.l(*szFileOut.p-ascii, *szKeyString.p-ascii, nOptions.l) As "RSA_SavePrivateKeyInfo"
RSA_SaveEncPrivateKey.l(*szFileOut.p-ascii, *szKeyString.p-ascii, nCount.l, *szPassword.p-ascii, nOptions.l) As "RSA_SaveEncPrivateKey"
RSA_KeyBits.l(*szKeyString.p-ascii) As "RSA_KeyBits"
RSA_KeyBytes.l(*szKeyString.p-ascii) As "RSA_KeyBytes"
RSA_ToXMLString.l(*szOutput.p-ascii, nOutChars.l, *szKeyString.p-ascii, nOptions.l) As "RSA_ToXMLString"
RSA_FromXMLString.l(*szOutput.p-ascii, nOutChars.l, *szXmlString.p-ascii, nOptions.l) As "RSA_FromXMLString"
RSA_CheckKey.l(*szKeyString.p-ascii, nOptions.l) As "RSA_CheckKey"
RSA_KeyHashCode.l(*szKeyString.p-ascii) As "RSA_KeyHashCode"
RSA_KeyMatch.l(*szPrivateKey.p-ascii, *szPublicKey.p-ascii) As "RSA_KeyMatch"
RSA_ReadPrivateKeyFromPFX.l(*szOutput.p-ascii, nOutChars.l, *szPfxFile.p-ascii, *szPassword.p-ascii, nOptions.l) As "RSA_ReadPrivateKeyFromPFX"
RSA_PublicKeyFromPrivate.l(*szOutput.p-ascii, nOutChars.l, *szKeyString.p-ascii, nOptions.l) As "RSA_PublicKeyFromPrivate"
; New in v10.0
RSA_ReadAnyPrivateKey.l(*szOutput.p-ascii, nOutChars.l, *szKeyFileOrString.p-ascii, *szPassword.p-ascii, nOptions.l) As "RSA_ReadAnyPrivateKey"
RSA_ReadAnyPublicKey.l(*szOutput.p-ascii, nOutChars.l, *szKeyFileOrString.p-ascii, nOptions.l) As "RSA_ReadAnyPublicKey"
RSA_KeyValue.l(*szOutput.p-ascii, nOutChars.l, *szKeyString.p-ascii, *szFieldName.p-ascii, nOptions.l) As "RSA_KeyValue"
; 'RAW' RSA ENCRYPTION/DECRYPTION FUNCTIONS
RSA_RawPublic.l(*lpData.p-ascii, nDataLen.l, *szPublicKey.p-ascii, nOptions.l) As "RSA_RawPublic"
RSA_RawPrivate.l(*lpData.p-ascii, nDataLen.l, *szPrivateKey.p-ascii, nOptions.l) As "RSA_RawPrivate"
RSA_EncodeMsg.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nInputLen.l, nOptions.l) As "RSA_EncodeMsg"
RSA_DecodeMsg.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nInputLen.l, nOptions.l) As "RSA_DecodeMsg"
; ELLIPTIC CURVE CRYPTOGRAPHY FUNCTIONS
; New in v11.0
ECC_MakeKeys.l(*szPubKeyFile.p-ascii, *szPriKeyFile.p-ascii, *szCurveName.p-ascii, *szPassword.p-ascii, *szParams.p-ascii, nOptions.l) As "ECC_MakeKeys"
ECC_ReadKeyByCurve.l(*szOutput.p-ascii, nOutChars.l, *szHexKey.p-ascii, *szCurveName.p-ascii, nOptions.l) As "ECC_ReadKeyByCurve"
ECC_ReadPrivateKey.l(*szOutput.p-ascii, nOutChars.l, *szKeyFileOrString.p-ascii, *szPassword.p-ascii, nOptions.l) As "ECC_ReadPrivateKey"
ECC_ReadPublicKey.l(*szOutput.p-ascii, nOutChars.l, *szKeyFileOrString.p-ascii, nOptions.l) As "ECC_ReadPublicKey"
ECC_SaveEncKey.l(*szFileOut.p-ascii, *szIntKeyString.p-ascii, *szPassword.p-ascii, *szParams.p-ascii, nOptions.l) As "ECC_SaveEncKey"
ECC_SaveKey.l(*szFileOut.p-ascii, *szIntKeyString.p-ascii, nOptions.l) As "ECC_SaveKey"
ECC_PublicKeyFromPrivate.l(*szOutput.p-ascii, nOutChars.l, *szIntKeyString.p-ascii, nOptions.l) As "ECC_PublicKeyFromPrivate"
ECC_QueryKey.l(szOutput.p-ascii, nOutChars.l, *szIntKeyString.p-ascii, *szQuery.p-ascii, nOptions.l) As "ECC_QueryKey"
; PKCS12 FILE FUNCTIONS
PFX_MakeFile.l(*szFileOut.p-ascii, *szCertFile.p-ascii, *szEpkFile.p-ascii, *szPassword.p-ascii, *szFriendlyName.p-ascii, nOptions.l) As "PFX_MakeFile"
PFX_VerifySig.l(*szFileName.p-ascii, *szPassword.p-ascii, nOptions.l) As "PFX_VerifySig"
; X509 CERTIFICATE FUNCTIONS
X509_MakeCert.l(*szNewCertFile.p-ascii, *szIssuerCertFile.p-ascii, *szSubjectPubKeyFile.p-ascii, *szIssuerEpkFile.p-ascii, nCertNum.l, nYearsValid.l, *szDistName.p-ascii, *szExtensions.p-ascii, nKeyUsageFlags.l, *szPassword.p-ascii, nOptions.l) As "X509_MakeCert"
X509_MakeCertSelf.l(*szNewCertFile.p-ascii, *szEpkFile.p-ascii, nCertNum.l, nYearsValid.l, *szDistName.p-ascii, *szExtensions.p-ascii, nKeyUsageFlags.l, *szPassword.p-ascii, nOptions.l) As "X509_MakeCertSelf"
X509_CertRequest.l(*szNewReqFile.p-ascii, *szEpkFile.p-ascii, *szDistName.p-ascii, *szReserved.p-ascii, *szPassword.p-ascii, nOptions.l) As "X509_CertRequest"
X509_VerifyCert.l(*szCertToVerify.p-ascii, *szIssuerCert.p-ascii, nOptions.l) As "X509_VerifyCert"
X509_CertThumb.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, nOptions.l) As "X509_CertThumb"
X509_CertIsValidNow.l(*szCertFile.p-ascii, nOptions.l) As "X509_CertIsValidNow"
X509_CertIssuedOn.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, nOptions.l) As "X509_CertIssuedOn"
X509_CertExpiresOn.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, nOptions.l) As "X509_CertExpiresOn"
X509_CertSerialNumber.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, nOptions.l) As "X509_CertSerialNumber"
X509_HashIssuerAndSN.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, nOptions.l) As "X509_HashIssuerAndSN"
X509_CertIssuerName.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, *szDelim.p-ascii, nOptions.l) As "X509_CertIssuerName"
X509_CertSubjectName.l(*szCertFile.p-ascii, *szOutput.p-ascii, nOutChars.l, *szDelim.p-ascii, nOptions.l) As "X509_CertSubjectName"
X509_GetCertFromP7Chain.l(*szNewCertFile.p-ascii, *szP7cFile.p-ascii, nIndex.l, nOptions.l) As "X509_GetCertFromP7Chain"
X509_GetCertFromPFX.l(*szNewCertFile.p-ascii, *szPfxFile.p-ascii, *szPassword.p-ascii, nOptions.l) As "X509_GetCertFromPFX"
X509_KeyUsageFlags.l(*szCertFile.p-ascii) As "X509_KeyUsageFlags"
X509_QueryCert.l(*szOutput.p-ascii, nOutChars.l, *szCertFile.p-ascii, *szQuery.p-ascii, nOptions.l) As "X509_QueryCert"
X509_ReadStringFromFile.l(*szOutput.p-ascii, nOutChars.l, *szCertFile.p-ascii, nOptions.l) As "X509_ReadStringFromFile"
X509_SaveFileFromString.l(*szNewCertFile.p-ascii, *szCertString.p-ascii, nOptions.l) As "X509_SaveFileFromString"
X509_TextDump.l(*szFileOut.p-ascii, *szCertFile.p-ascii, nOptions.l) As "X509_TextDump"
X509_ValidatePath.l(*szCertListOrP7File.p-ascii, *szTrustedCert.p-ascii, nOptions.l) As "X509_ValidatePath"
; X509 CRL FUNCTIONS
X509_MakeCRL.l(*szCrlFile.p-ascii, *szIssuerCert.p-ascii, *szIssuerKeyFile.p-ascii, *szPassword.p-ascii, *szRevokedCertList.p-ascii, *szExtensions.p-ascii, nOptions.l) As "X509_MakeCRL"
X509_CheckCertInCRL.l(*szCertFile.p-ascii, *szCrlFile.p-ascii, *szCRLIssuerCert.p-ascii, *szDate.p-ascii, nOptions.l) As "X509_CheckCertInCRL"
; ONLINE CERTIFICATE STATUS PROTOCOL .l(OCSP) FUNCTIONS as "CERTIFICATE STATUS PROTOCOL "
OCSP_MakeRequest.l(*szOutput.p-ascii, nOutChars.l, *szIssuerCert.p-ascii, *szCertFileOrSerialNum.p-ascii, *szExtensions.p-ascii, nOptions.l) As "OCSP_MakeRequest"
OCSP_ReadResponse.l(*szOutput.p-ascii, nOutChars.l, *szResponseFile.p-ascii, *szIssuerCert.p-ascii, *szExtensions.p-ascii, nOptions.l) As "OCSP_ReadResponse"
; TRIPLE DES FUNCTIONS
TDEA_HexMode.l(*szOutput.p-ascii, *szInput.p-ascii, *szKey.p-ascii, fEncrypt.l, *szMode.p-ascii, *szIV.p-ascii) As "TDEA_HexMode"
TDEA_B64Mode.l(*szOutput.p-ascii, *szInput.p-ascii, *szKey.p-ascii, fEncrypt.l, *szMode.p-ascii, *szIV.p-ascii) As "TDEA_B64Mode"
TDEA_BytesMode.l(*lpOutput.p-ascii, *lpData.p-ascii, nDataLen.l, *lpKey.p-ascii, fEncrypt.l, *szMode.p-ascii, *lpIV.p-ascii) As "TDEA_BytesMode"
TDEA_File.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *lpKey.p-ascii, fEncrypt.l, *szMode.p-ascii, *lpIV.p-ascii) As "TDEA_File"
; GENERIC BLOCK CIPHER FUNCTIONS
CIPHER_Bytes.l(fEncrypt.l, *lpOutput.p-ascii, *lpData.p-ascii, nDataLen.l, *lpKey.p-ascii, *lpIV.p-ascii, *szAlgAndMode.p-ascii, nOptions.l) As "CIPHER_Bytes"
CIPHER_File.l(fEncrypt.l, *szFileOut.p-ascii, *szFileIn.p-ascii, *lpKey.p-ascii, *lpIV.p-ascii, *szAlgAndMode.p-ascii, nOptions.l) As "CIPHER_File"
CIPHER_Hex.l(fEncrypt.l, *szOutput.p-ascii, nOutChars.l, *szData.p-ascii, *szKey.p-ascii, *szIV.p-ascii, *szAlgAndMode.p-ascii, nOptions.l) As "CIPHER_Hex"
CIPHER_KeyWrap.l(*lpOutput.p-ascii, nOutBytes.l, *lpData.p-ascii, nDataLen.l, *lpKek.p-ascii, nKekLen.l, nOptions.l) As "CIPHER_KeyWrap"
CIPHER_KeyUnwrap.l(*lpOutput.p-ascii, nOutBytes.l, *lpData.p-ascii, nDataLen.l, *lpKek.p-ascii, nKekLen.l, nOptions.l) As "CIPHER_KeyUnwrap"
; Added [v3.10]
CIPHER_EncryptBytesPad.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nInputLen.l, *lpKey.p-ascii, *lpIV.p-ascii, *szAlgModePad.p-ascii, nOptions.l) As "CIPHER_EncryptBytesPad"
CIPHER_DecryptBytesPad.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nInputLen.l, *lpKey.p-ascii, *lpIV.p-ascii, *szAlgModePad.p-ascii, nOptions.l) As "CIPHER_DecryptBytesPad"
; MESSAGE DIGEST HASH FUNCTIONS
HASH_Bytes.l(*lpOutput.p-ascii, nOutBytes.l, *lpMessage, nMsgLen.l, nOptions.l) As "HASH_Bytes"
HASH_File.l(*lpOutput.p-ascii, nOutBytes.l, *szFileName.p-ascii, nOptions.l) As "HASH_File"
HASH_HexFromBytes.l(*szOutput.p-ascii, nOutChars.l, *lpMessage, nMsgLen.l, nOptions.l) As "HASH_HexFromBytes"
HASH_HexFromFile.l(*szOutput.p-ascii, nOutChars.l, *szFileName.p-ascii, nOptions.l) As "HASH_HexFromFile"
HASH_HexFromHex.l(*szOutput.p-ascii, nOutChars.l, *szMsgHex.p-ascii, nOptions.l) As "HASH_HexFromHex"
; HMAC FUNCTIONS
HMAC_Bytes.l(*lpOutput.p-ascii, nOutBytes.l, *lpMessage, nMsgLen.l, *lpKey, nKeyLen.l, nOptions.l) As "HMAC_Bytes"
HMAC_HexFromBytes.l(*szOutput.p-ascii, nOutChars.l, *lpMessage, nMsgLen.l, *lpKey, nKeyLen.l, nOptions.l) As "HMAC_HexFromBytes"
HMAC_HexFromHex.l(*szOutput.p-ascii, nOutChars.l, *szMsgHex.p-ascii, *szKeyHex.p-ascii, nOptions.l) As "HMAC_HexFromHex"
; BASE64 AND HEX CONVERSION FUNCTIONS
CNV_B64StrFromBytes.l(*szOutput.p-ascii, nOutChars.l, *lpInput.p-ascii, nInputLen.l) As "CNV_B64StrFromBytes"
CNV_BytesFromB64Str.l(*lpOutput.p-ascii, nOutBytes.l, *szInput.p-ascii) As "CNV_BytesFromB64Str"
CNV_B64Filter.l(*szOutput.p-ascii, *szInput.p-ascii, nStrLen.l) As "CNV_B64Filter"
CNV_HexStrFromBytes.l(*szOutput.p-ascii, nOutChars.l, *lpInput.p-ascii, nInputLen.l) As "CNV_HexStrFromBytes"
CNV_BytesFromHexStr.l(*lpOutput.p-ascii, nOutBytes.l, *szInput.p-ascii) As "CNV_BytesFromHexStr"
CNV_HexFilter.l(*szOutput.p-ascii, *szInput.p-ascii, nStrLen.l) As "CNV_HexFilter"
; BASE58 FUNCTIONS
; New in v11.0
CNV_Base58FromBytes.l(*szOutput.p-ascii, nOutChars.l, *lpInput.p-ascii, nInputLen.l) As "CNV_Base58FromBytes"
CNV_Base58ToBytes.l(*lpOutput.p-ascii, nOutBytes.l, *szInput.p-ascii) As "CNV_Base58ToBytes"
; UTF-8 CONVERSION/CHECK FUNCTIONS
; [Note: the following three functions are deprecated as of v3.6]
CNV_UTF8FromLatin1.l(*szOutput.p-ascii, nOutChars.l, *szInput.p-ascii) As "CNV_UTF8FromLatin1"
CNV_Latin1FromUTF8.l(*szOutput.p-ascii, nOutChars.l, *szInput.p-ascii) As "CNV_Latin1FromUTF8"
CNV_CheckUTF8.l(*szInput.p-ascii) As "CNV_CheckUTF8"
; [New in v3.6]
CNV_UTF8BytesFromLatin1.l(*lpOutput.p-ascii, nOutBytes.l, *szInput.p-ascii) As "CNV_UTF8BytesFromLatin1"
CNV_Latin1FromUTF8Bytes.l(*szOutput.p-ascii, nOutChars.l, *lpInput.p-ascii, nBytes.l) As "CNV_Latin1FromUTF8Bytes"
CNV_CheckUTF8Bytes.l(*lpInput.p-ascii, nBytes.l) As "CNV_CheckUTF8Bytes"
CNV_CheckUTF8File.l(*szFileName.p-ascii) As "CNV_CheckUTF8File"
CNV_ByteEncoding.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nBytes.l, nOptions.l) As "CNV_ByteEncoding"
; MISC BYTE UTILITIES
; New in v11.0
CNV_ReverseBytes.l(*lpOutput.p-ascii, *lpInput.p-ascii, nBytes.l) As "CNV_ReverseBytes"
CNV_NumToBytes.l(*lpOutput.p-ascii, nOutBytes.l, nNumber.l, nOptions.l) As "CNV_NumToBytes"
CNV_NumFromBytes.l(*lpInput.p-ascii, nBytes.l, nOptions.l) As "CNV_NumFromBytes"
; PEM/BINARY FILE CONVERSIONS
PEM_FileFromBinFile.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *szHeader.p-ascii, nLineLen.l) As "PEM_FileFromBinFile"
PEM_FileFromBinFileEx.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *szHeader.p-ascii, nLineLen.l, nOptions.l) As "PEM_FileFromBinFileEx"
PEM_FileToBinFile.l(*szFileOut.p-ascii, *szFileIn.p-ascii) As "PEM_FileToBinFile"
; RNG FUNCTIONS
RNG_Bytes.l(*lpOutput.p-ascii, nOutBytes.l, *lpSeed, nSeedLen.l) As "RNG_Bytes"
RNG_Number.l(nLower.l, nUpper.l) As "RNG_Number"
RNG_BytesWithPrompt.l(*lpOutput.p-ascii, nOutBytes.l, *szPrompt.p-ascii, nOptions.l) As "RNG_BytesWithPrompt"
RNG_Initialize.l(*szSeedFile.p-ascii, nOptions.l) As "RNG_Initialize"
RNG_MakeSeedFile.l(*szSeedFile.p-ascii, *szPrompt.p-ascii, nOptions.l) As "RNG_MakeSeedFile"
RNG_UpdateSeedFile.l(*szSeedFile.p-ascii, nOptions.l) As "RNG_UpdateSeedFile"
RNG_Test.l(*szFileOut.p-ascii, nOptions.l) As "RNG_Test"
; PADDING FUNCTIONS
PAD_BytesBlock.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nInputLen.l, nBlkLen.l, nOptions.l) As "PAD_BytesBlock"
PAD_UnpadBytes.l(*lpOutput.p-ascii, nOutBytes.l, *lpInput.p-ascii, nInputLen.l, nBlkLen.l, nOptions.l) As "PAD_UnpadBytes"
PAD_HexBlock.l(*szOutput.p-ascii, nOutChars.l, *szInput.p-ascii, nBlkLen.l, nOptions.l) As "PAD_HexBlock"
PAD_UnpadHex.l(*szOutput.p-ascii, nOutChars.l, *szInput.p-ascii, nBlkLen.l, nOptions.l) As "PAD_UnpadHex"
; MISC UTILITIES
WIPE_File.l(*szFileName.p-ascii, nOptions.l) As "WIPE_File"
WIPE_Data.l(*lpData, nDataLen.l) As "WIPE_Data"
PWD_Prompt.l(*szPassword.p-ascii, nPwdLen.l, *szCaption.p-ascii) As "PWD_Prompt"
PWD_PromptEx.l(*szPassword.p-ascii, nPwdLen.l, *szCaption.p-ascii, *szPrompt.p-ascii, nOptions.l) As "PWD_PromptEx"
; PASSWORD-BASED ENCRYPTION PROTOTYPES
; [New in v3.10]
PBE_Kdf2.l(*lpOutput.p-ascii, nOutBytes.l, *lpPwd.p-ascii, nPwdLen.l, *lpSalt.p-ascii, nSaltLen.l, nCount.l, nOptions.l) As "PBE_Kdf2"
PBE_Kdf2Hex.l(*szOutput.p-ascii, nOutChars.l, dkBytes.l, *szPwd.p-ascii, *szSaltHex.p-ascii, nCount.l, nOptions.l) As "PBE_Kdf2Hex"
; ASN.1 UTILITIES
; [New in v10.0]
ASN1_TextDump.l(*szFileOut.p-ascii, *szFileOrPEMString.p-ascii, nOptions.l) As "ASN1_TextDump"
ASN1_Type.l(*szOutput.p-ascii, nOutChars.l, *szFileOrPEMString.p-ascii, nOptions.l) As "ASN1_Type"
; SIGNATURE FUNCTIONS
; [New in v10.0]
SIG_SignData.l(*szOutput.p-ascii, nOutChars.l, *lpData.p-ascii, nDataLen.l, *szKeyFile.p-ascii, *szPassword.p-ascii, *szAlgName.p-ascii, nOptions.l) As "SIG_SignData"
SIG_SignFile.l(*szOutput.p-ascii, nOutChars.l, *szDataFile.p-ascii, *szKeyFile.p-ascii, *szPassword.p-ascii, *szAlgName.p-ascii, nOptions.l) As "SIG_SignFile"
SIG_VerifyData.l(*szSignature.p-ascii, *lpData.p-ascii, nDataLen.l, *szCertOrKeyFile.p-ascii, *szAlgName.p-ascii, nOptions.l) As "SIG_VerifyData"
SIG_VerifyFile.l(*szSignature.p-ascii, *szDataFile.p-ascii, *szCertOrKeyFile.p-ascii, *szAlgName.p-ascii, nOptions.l) As "SIG_VerifyFile"
; SMIME FUNCTIONS
; [New in v10.0]
SMIME_Wrap.l(*szFileOut.p-ascii, *szFileIn.p-ascii, *szFeatures.p-ascii, nOptions.l) As "SMIME_Wrap"
SMIME_Extract.l(*szFileOut.p-ascii, *szFileIn.p-ascii, nOptions.l) As "SMIME_Extract"
SMIME_Query.l(*szOutput.p-ascii, nOutChars.l, *szFileIn.p-ascii, *szQuery.p-ascii, nOptions.l) As "SMIME_Query"
EndImport
Re: Public private key for file exchange
Hello seeker!
Thanks a lot for the link and the source!
I thought of an easier way to handle this.
Explanation: I have to build all the keys and only want the users not being able to fake file-messages themselves.
A P2P-network is considered evil today (due to file exchange), but is the future of free, connected users.
At our site, connection between peers are also only possible by indirection.
And having to trust servers causes a tremendous overhead of administration, etc.
Thanks a lot for the link and the source!
I thought of an easier way to handle this.
Explanation: I have to build all the keys and only want the users not being able to fake file-messages themselves.
A P2P-network is considered evil today (due to file exchange), but is the future of free, connected users.
At our site, connection between peers are also only possible by indirection.
And having to trust servers causes a tremendous overhead of administration, etc.
Re: Public private key for file exchange
I will use a decryption and if it's successful the user is known.
Forgot that a 'central' peer handles the file exchange; so if decryption works -> user known!
Forgot that a 'central' peer handles the file exchange; so if decryption works -> user known!
Re: Public private key for file exchange
maybe you could use this?
http://www.purebasic.fr/english/viewtop ... 2&start=15
http://www.purebasic.fr/english/viewtop ... 2&start=15
Windows 11, Manjaro, Raspberry Pi OS

