
kroman82
Members-
Posts
10 -
Joined
-
Last visited
Everything posted by kroman82
-
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
Thank you very much argumentum ! -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
sorry, I'm found that... -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
yes, I'm want to: I'm tryed to find internal function by this keyword __CryptoNG_BcryptImportKeyPair but can't find... -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
Hello TheXman I have a question that again goes a little beyond the scope of this UDF but may be your or anybody else can help me please? question: How can I encrypt a message with a public key (yes, the new RSABLOB format) without saving the public key to file? I have a binary format public key $serverPubkey = 525341310008000003000000000100000000000000000000010001c8f5ec669823656ebd398d7a3678980aed425cacb1699829103e2c5d3c0dfbd3ad485c86e20e282125837a051a595fa8fecb18e6111208685f5a363226330052f61f9aeac61f7037b294027231327207caf85d181bf69f88969464f57877b9cfdf1a712178f64eb384bef0ea83c1eb8afc8182a7d9ae4d899a091a7b3e2b835f27224955312fd8de31bec7677eebe0f9d35023ae3af187f4941d8f19164be6757981c5f498fbcb88bcdf08c9806ba70bd428c7da73c30a9483404bef917c1eaa3fbd63e2607ccd81325be1e15c1d6233c23c860ca0c3eecf6f5b9a12e9bb4dd02e99c8fa2315d756919d3f351933b9281d6272275a5e413f7fbaf29b486654ab and tryed to use it in a function Func _CryptoNG_RSA_EncryptData($sText, $sPublicKeyBlobFile = Binary('0x'&$serverPubkey), $iPadding = Default, $sProvider = Default) and again Func _CryptoNG_RSA_EncryptData($sText, $sPublicKeyBlobFile = Binary($serverPubkey), $iPadding = Default, $sProvider = Default) and other crazy variants with no luck... -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
I'm started to read your hints and found this: LEGACY_RSAPUBLIC_BLOB The BLOB is an RSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support importing this BLOB type. This is too hard to me... Anyway - Thank you very much! (sorry for bothering you) -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
replacing header... -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
Thank you very much TheXman ! You make my day! So one issue gone... now I'm have the last one issue (this is out of scope, but may be...): It would be nice to find solution how to convert PEM-formatted public key to "RSA blob" format (CryptoNG API's) (I'm not sure but maybe it can be done just a moving header from "MS blob" file to "RSA blob" file) -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
got some result from "debug" blob files: if a blob file generated with function "create_legacy_rsa_key_pair_example()" this is generate public key RSA1 file started with some strange symblols and this file can be converted to PEM format with openssl --inform "MS PUBLICKEYBLOB" (may be opposite way --outform can be correct too) this file can be used with openssl but can not be used for encrypt messages with your UDF if a blob file generated with function "rsa_public_private_key_encrypt_decrypt_data_example()" this is generate public key RSA1 file started with RSA1 it can be used for encrypt messages with your UDF and this file can be converted to PEM format with openssl --inform "MS PUBLICKEYBLOB" but can not be used with openssl even if converted so question how to convert blob file from "MS BLOB" (new format?) to openssl PEM format in right way.... or may be other ways to encrypt messages from "client" with private + public key generated from your UDF (MS Crypto API) thats are compatible with openssl ? -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
Thank you for your attention! I'm am not used your example private key , because I'm try to encrypt only (sorry, next full code of your example function): Func rsa_public_private_key_encrypt_decrypt_data_example() Const $ALG_ID = $CNG_BCRYPT_RSA_ALGORITHM, _ $MESSAGE = "This is a super-secret message.", _ $PUBLIC_KEY_FILE = "pubkey_server.blob", _ $PRIVATE_KEY_FILE = "example_rsa_privatekey.blob" Local $sDecryptedMessage = "" Local $xEncryptedMessage = Binary("") ;~ ;Create RSA Public/Private Key Pair (Uncomment section below to create a new key pair) ; _CryptoNG_RSA_CreateKeyPair(2048, $PUBLIC_KEY_FILE, $PRIVATE_KEY_FILE, $CNG_BCRYPT_RSA_KEY_EXPORT_RSA) ; If @error Then ; write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) ; Return False ; EndIf ;Encrypt plain text message $xEncryptedMessage = _CryptoNG_RSA_EncryptData($MESSAGE, $PUBLIC_KEY_FILE) If @error Then write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Return False EndIf ;Decrypt encrypted message ; $sDecryptedMessage = _CryptoNG_RSA_DecryptData($xEncryptedMessage, $PRIVATE_KEY_FILE) ; If @error Then ; write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) ; Return False ; EndIf ;Display results write_to_log(@CRLF) write_to_log("CryptoNG Asymmetric Public/Private Key Encrypt/Decrypt Example" & @CRLF) write_to_log(StringFormat("%s Public key file = %s", $ALG_ID, $PUBLIC_KEY_FILE) & @CRLF) write_to_log(StringFormat("%s Private key file = %s", $ALG_ID, $PRIVATE_KEY_FILE) & @CRLF) write_to_log(StringFormat("%s Plain text message = %s", $ALG_ID, $MESSAGE) & @CRLF) write_to_log(StringFormat("%s Encrypted Message = %s", $ALG_ID, $xEncryptedMessage) & @CRLF) write_to_log(StringFormat("%s Decrypted Message = %s", $ALG_ID, $sDecryptedMessage) & @CRLF) EndFunc And generated private key is holds on server which generating key pair (public key + private key) first And only "owner of private key" (my server) can decrypt encrypted message From your UDF I'm want only encrypting - thats why I'm using my public key About generating key pair : I'm using openssl with rsa option and generates rsa key pair Than I'm convert public key to "MS PUBLICKEYBLOB" format - this is same format what you write in your examples So I'm not expected issues on first step = when I'm try to encrypt the message with public key one difference is that key pair was generated via openssl not your UDF I'm confused and need a help ( -
CryptoNG UDF - Cryptography API: Next Gen
kroman82 replied to TheXman's topic in AutoIt Example Scripts
Hello TheXman Thank you very much for your UDF! Sorry my english! I'm try to use this with windows and linux and have some problem ( func "rsa_public_private_key_encrypt_decrypt_data_example()" works well Than I'm create public+private key pair in Ubuntu with openssl: openssl genrsa -out privkey.pem 1024 openssl rsa -in privkey.pem -pubout -out pubkey_server.blob -outform "MS PUBLICKEYBLOB" and transfer pubkey_server.blob to windows next I'm insert this public key into your example Func rsa_public_private_key_encrypt_decrypt_data_example() Const $ALG_ID = $CNG_BCRYPT_RSA_ALGORITHM, _ $MESSAGE = "This is a super-secret message.", _ $PUBLIC_KEY_FILE = "pubkey_server.blob", _ $PRIVATE_KEY_FILE = "example_rsa_privatekey.blob" Local $sDecryptedMessage = "" Local $xEncryptedMessage = Binary("") and get error ERROR: Bad data supplied to function. Done My goal is -> get public key from "server" -> than encrypt data (text message for example) and -> send data to server server must can decrypt this message. Please, can you help me to solve this issue? Where I'm wrong? Is this "padding" issue? Too many questions... sorry!