TheXman Posted November 13, 2024 Author Posted November 13, 2024 (edited) 6 hours ago, konya said: Use _CryptoNG_RSA_EncryptData($Private_c , $Public_key, $CNG_BCRYPT_PAD_NONE ) it is can let public key decrypt. @konya In practice, RSA encryption should ALWAYS use a padding scheme. I'm pretty sure that Microsoft's CNG RSA encryption/decryption implementation, with no padding, will generate some sort of "invalid parameter" exception. It needs to be PKCS1 or OAEP (at least this is true using the default Microsoft Primitive Provider). Also, did you really mean to suggest that, using RSA encryption/decryption, an RSA public key can be used to both encrypt and decrypt a message? Edited November 13, 2024 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
konya Posted November 14, 2024 Posted November 14, 2024 (edited) @TheXman When I use the default setting $CNG_BCRYPT_PAD_PKCS1 , public key decryption will return An invalid parameter was passed to a service of function, but when setting $CNG_BCRYPT_PAD_NONE it is decryption success,result the same openssl_public_decrypt function and I don't know why PHP & openssl want support public key decryption private key ciphertext. When I use other UDF like bignum ,verify result as below : $m = "I like autoit" $c = _BigNum_PowerMod($m, $d, $n) ;Private key encrypt $m = _BigNum_PowerMod($c, $e, $n) ;Public key decrypt Result $m = "I like autoit" or $m = "" $c = _BigNum_PowerMod($m, $e, $n) ;Public key encrypt $m = _BigNum_PowerMod($c, $d, $n) ;Private key decrypt Result $m = "I like autoit" It would be great if the _BigNum_PowerMod performance could be improved,it is need 10second provide the result. Edited November 14, 2024 by konya Read Public or Pravite key information data tool (Read PEM) GDI+ Image deskew and crop
TheXman Posted November 14, 2024 Author Posted November 14, 2024 (edited) @konya Post a test script using CryptoNG, that I can run, that proves what you are saying is true. I want to see the actual values that you are using and how you are using the CryptoNG functions.. For the record, the "Invalid Parameter" error can be caused by things other than just padding. That is Microsoft's general error saying that one or more of the parameters passed to the API is invalid. The RSA example that I provide with CryptoNG proves that the encryption and decryption functions work correctly. If you are using the code that you posted earlier that manually creates RSA key blobs, then that may be the problem. Show me an example that uses valid RSA keys. You can create them with CryptoNG or any other tool that generates valid RSA-formatted key blobs. If you haven't yet, make sure you read the remarks in the CryptoNG help file under the function _CryptoNG_RSA_CreateKeyPair(). There are 2 types of RSA key formats that can be generated, the older legacy RSA keys and the newer RSA-formatted keys. You need to understand the difference and make sure that you are using the correct format. Edited November 14, 2024 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
konya Posted November 14, 2024 Posted November 14, 2024 (edited) @TheXman I use your example blob key make a sample,you can check. $hex_c = Binary("0x598218CBE9826AAF525FA728DB78DCFE2A81F886FC2C35BD40A29662BCCA5FBB224814C1C97157DB619E19A6980BBC39510663B0289F49E8F7551C02F918D44119E7A41B669A31D4A9AB72AFA9531626D25767FE108822A8444318A3A2046ACD7CCE91B358FBEB9E643EFDD1A4688FED197188579AFD563CD1E184D21F837B685402BF633FF9B371F19EB466F2C8290683C447803E3D1CA0AFB516CC8FF1B333EACCB0D453E33886C0CAD933B9A198BC7A43C20651BA04935D73E1AA0503D6BE5574FB35D5FCCF62D5D68930332F3B8D568CDF1540F03E3A9C863704509AD973E12D05812FE4E425BD745B59DAF531F0E4B1D5D89E569C543FCFBF75BF1A70BA") $m = _CryptoNG_RSA_EncryptData($hex_c , "example_rsa_publickey.blob", $CNG_BCRYPT_PAD_NONE, Default ) If @error Then MsgBox(0,"",_CryptoNG_LastErrorMessage()) Else $m = Hex($m) $search_zero = StringInStr($m,"FF00") MsgBox(0,"",BinaryToString("0x"&StringMid($m,$search_zero+4,StringLen($m)-$search_zero))) EndIf Edited November 14, 2024 by konya Read Public or Pravite key information data tool (Read PEM) GDI+ Image deskew and crop
TheXman Posted November 14, 2024 Author Posted November 14, 2024 (edited) @konya The example RSA public/private key pair are 2048 bits. The value that you are trying to encrypt is 256 bytes (2048 bits). You cannot encrypt 2048 bits with a 2048 bit key, using PKCS1 padding. That value is too large and it is the reason that you got an "Invalid Parameter" error when using padding. This was discussed in a previous post HERE. Edited November 14, 2024 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
konya Posted November 14, 2024 Posted November 14, 2024 @TheXman It is can use private key encrypt and public key decrypt no issue. Only share information and help any one. Read Public or Pravite key information data tool (Read PEM) GDI+ Image deskew and crop
TheXman Posted November 14, 2024 Author Posted November 14, 2024 (edited) 11 hours ago, konya said: It is can use private key encrypt and public key decrypt no issue. That is backwards! The public key is used to encrypt and the private key is used to decrypt. Edited November 14, 2024 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
kroman82 Posted February 22 Posted February 22 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! TheXman 1
TheXman Posted February 22 Author Posted February 22 (edited) If you used the parameters that you posted, why did you use my example private key with your newly generate public key? RSA uses public/private key pairs. If you want to test your newly generated keys using the provided example function, then you would need to use your newly generated public/private key pair as parameters. You can't mix & match RSA key pairs and expect that function to be able to encrypt and decrypt a message. If you want to be able to use externally created RSA key pairs (like the ones generated by openssl) with CryptoNG APIs, make sure that you read & understand the information in the "Remarks" section of the _CryptoNG_RSA_CreateKeyPair() entry in the CryptoNG help file. Microsoft's CryptoNG encryption/decryption functions can only import and use RSA-formatted keys. Edited February 22 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
kroman82 Posted February 22 Posted February 22 Thank you for your attention! 2 hours ago, TheXman said: why did you use my example private key with your newly generate public key? I'm am not used your example private key , because I'm try to encrypt only (sorry, next full code of your example function): expandcollapse popupFunc 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 (
kroman82 Posted February 22 Posted February 22 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 ?
TheXman Posted February 22 Author Posted February 22 (edited) I was going to reply earlier to clear up some of your confusion, but I decided to wait until I figured out a good solution. First, working with RSA keys IS very confusing, especially when you are working with CryptoNG (BCRYPT) RSA API's. Part of the reason is that CryptoNG RSA API's use RSA KEYBLOB files, not MS KEYBLOB files. MS KEYBLOB files are the blob files that were used with the deprecated CryptoAPI (ADVAPI32) API's and also the type that can be generated by OpenSSL. Unfortunately, OpenSSL does not have a way to create RSA KEYBLOB files -- at least not to my knowledge. You were trying to use MS KEYBLOB files with CryptoNG API's and that will not work. There are several other things that make working with RSA key pairs confusing, especially when you add in 3rd party tools like OpenSSL for key pair generation. As you have probably figured out, the CryptoNG UDF library function that creates RSA key pairs only exports them in one format or the other (RSA or Legacy). I am creating an extended function that will export both formats at once. Having both blob formats, you can use the RSA blob format for AutoIt CryptoNG functions to encrypt or decrrypt and use the legacy blob format (MS BLOBKEY) to convert the keys for use by other processes and libraries using the PEM or DER format. The OpenSSL conversion commands to convert legacy blob files to PEM or DER are in the CryptoNG Help File that is supplied with the UDF library. Give me about an hour to create the new function and test it. I will post it here when I'm done. Edited February 23 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
TheXman Posted February 22 Author Posted February 22 (edited) @kroman82 I have uploaded a new version of CryptoNG. The new version includes a function (_CryptoNG_RSA_CreateKeyPairEx) that will export both types of blob files (RSA and MS/Legacy). The RSA blob files are needed by Microsoft's CryptoNG API's (which are what my UDF creates wrappers for). The MS blob files can be used to generate PEM or DER files that can be used with OpenSSL or any other crypto library that has RSA functions. Here is an updated CryptoNG example that uses the new function: expandcollapse popupFunc rsa_public_private_key_encrypt_decrypt_data_example() Const $ALG_ID = $CNG_BCRYPT_RSA_ALGORITHM, _ $MESSAGE = "This is a super-secret message.", _ $RSA_PUBLIC_KEY_FILE = "rsa_publickey.blob", _ $RSA_PRIVATE_KEY_FILE = "rsa_privatekey.blob", _ $MS_PUBLIC_KEY_FILE = "ms_publickey.blob", _ $MS_PRIVATE_KEY_FILE = "ms_privatekey.blob" Local $sDecryptedMessage = "" Local $xEncryptedMessage = Binary("") ;Create RSA Public/Private Key Pair _CryptoNG_RSA_CreateKeyPairEx(1024, $RSA_PUBLIC_KEY_FILE, $RSA_PRIVATE_KEY_FILE, $MS_PUBLIC_KEY_FILE, $MS_PRIVATE_KEY_FILE) If @error Then write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Return False EndIf ;Encrypt plain text message $xEncryptedMessage = _CryptoNG_RSA_EncryptData($MESSAGE, $RSA_PUBLIC_KEY_FILE) If @error Then write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Return False EndIf ;Decrypt encrypted message $sDecryptedMessage = _CryptoNG_RSA_DecryptData($xEncryptedMessage, $RSA_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, $RSA_PUBLIC_KEY_FILE) & @CRLF) write_to_log(StringFormat("%s Private key file = %s", $ALG_ID, $RSA_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 Result: CryptoNG UDF v2.3.0 CryptoNG Asymmetric Public/Private Key Encrypt/Decrypt Example RSA Public key file = rsa_publickey.blob RSA Private key file = rsa_privatekey.blob RSA Plain text message = This is a super-secret message. RSA Encrypted Message = 0x09240F7929B217338E10B94C6B481027C61B1C41080A806C02019A724B06991190BEFF5A27FBF17E0E6550067FAEAAB504936B2F4A55C0C2CC37F788B18C276CC31DCD339A5084FFF66A12E9598EF79432975EEE7A347F899AA38661B2FF3330418882F29A8B52012D8B57B85CF4DBD9924D7C606BE3A056FD66295B2D139B32 RSA Decrypted Message = This is a super-secret message. Done Upon successful execution of _CryptoNG_RSA_CreateKeyPairEx(), you should see the 4 blob files. To create PEM public/private key files for use by your server or other RSA crypto library functions, you can use OpenSSL to create PEM files like this. You can also create DER files by changing the -outform parameter. OpenSSL commands to convert MS KEYBLOB files to PEM files ---------------------------------------------------------- openssl rsa -pubin -inform "MS PUBLICKEYBLOB" -in ms_publickey.blob -outform PEM -out ms_publickey.pem openssl rsa -inform "MS PRIVATEKEYBLOB" -in ms_privatekey.blob -outform PEM -out ms_privatekey.pem Edited February 22 by TheXman argumentum and kroman82 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
kroman82 Posted February 22 Posted February 22 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) TheXman 1
kroman82 Posted February 22 Posted February 22 Just now, kroman82 said: 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) replacing header...
TheXman Posted February 22 Author Posted February 22 (edited) 36 minutes ago, kroman82 said: Thank you very much TheXman ! You make my day! You're welcome! 36 minutes ago, kroman82 said: It would be nice to find solution how to convert PEM-formatted public key to "RSA blob" format (CryptoNG API's) Creating such a function wouldn't be very difficult at all. Actually, the API wrappers/functions to read in a legacy private key blob file and create either (or both) the rsa public and private key blob files already exist in the UDF library. Or, as you suggested, the same could be done with just the public key blob file. I could post such a function but where's the fun in that for others that may want to try to do it themselves? OpenSSL already has the ability to convert PEM's to legacy blob files. So those blob files could be used as input to a CryptoNG function that converts them to rsa blob files. Hint: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptimportkeypair https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptexportkey Edited February 22 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
kroman82 Posted February 22 Posted February 22 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)
TheXman Posted February 22 Author Posted February 22 9 minutes ago, kroman82 said: 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. Ah yes, you're right. I forgot about that. You cannot import a LEGACY_RSAPUBLIC_BLOB using BCryptImportKeyPair. However, you can import a LEGACY_RSAPRIVATE_BLOB (if it is available). And from that LEGACY_RSAPRIVATE_BLOB, you can export an RSA public key blob and/or an RSA private key blob. The conversion of just a legacy public key blob or PEM to an RSA public key blob would be a little more difficult...but still doable. I'll put that on my list of feature requests for CryptoNG. Musashi and kroman82 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
kroman82 Posted February 25 Posted February 25 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... TheXman 1
TheXman Posted February 25 Author Posted February 25 (edited) It appears that you want to store the public key blob in a variable or constant within you script and use it to encrypt data. If that's correct, then you can do that, but you will need to use a modified version of the internal __CryptoNG_BcryptImportKeyPair() function. Currently, that internal function reads in the public key blob from a specified file. All you would need to do is create a version of that function that reads the public key blob from your variable or constant instead. You would also need a slightly modified version of _CryptoNG_RSA_EncryptData() that passes that variable or constant to you modified version of __CryptoNG_BcryptImportKeyPair(). Another solution, which wouldn't require modifications to any of the existing CryptoNG functions, would be to embed the blob file in the script and have the script copy the file to the local file system using FileInstall(). Since it's a public key, you could leave it on the file system after your script exits. If you don't want to leave it, then you could just have the script delete it when you're finished with it. Edited February 25 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now