• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

RSA Encryption Help with Bouncy Castle

New Here ,
Apr 08, 2007 Apr 08, 2007

Copy link to clipboard

Copied

Does anyone have experience doing RSA encryption with Bouncy Castle installed as a security provider?

For example, what is the proper syntax of the Encrypt(string, key[, algorithm[, encoding]])) function to send an RSA encrypted string to someone given the following values:

string = "This is the string to encrypt"
RSA Public Key Moduls = qFP+TNkUxiwqgYkce7iBR1Z2VndmSDLlxM0UQEW5UQQPdTWdEl6iIjteIZr5M9R6EBsGh6XKHG7et9SAJ/0h/OwBJMOaoGpoQq2IJHKqKA4UhC30fnFZcfVz6ne4dTUemkJinIUiSlHLaChdANoe9lC9wNVGu1tUpkiwj+Pn4/c=
RSA Public Key Exponent = AQAB
Padding = pKCS#1 v1.5

Thanks in advance for any help you can provide.
TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 09, 2007 Apr 09, 2007

Copy link to clipboard

Copied

<cfsavecontent variable="myText">
This is a bunch of text that will
be encrypted in the file.
</cfsavecontent>


<cfset myKey = ToBase64("F00BarKey")>

<b>Encrypted Key</b>
<p>
<cfoutput>#myKey#</cfoutput>
</p>

<cfset crypText = Encrypt(myText,myKey,"twofish")>

<cfset deCryptText = Decrypt(crypText,myKey,"twofish")>
<b>Encrypted Text</b>
<p>
<cfoutput>#crypText#</cfoutput>
</p>
<p>
<b>Un-Encrypted Text</b>
<p>
<cfoutput>#deCryptText#</cfoutput>
</p>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2007 Apr 09, 2007

Copy link to clipboard

Copied

LATEST
Hi, Thanks for your reply. A couple of clarifications. I need to use the public key provided by the a 3rd party that I am sending encrypted data to, and I must use RSA encryption. I believe what I am looking for will be something like:

<cfsavecontent variable="myText">
This is a bunch of text that will
be encrypted in the file.
</cfsavecontent>

<cfset myText_encrypted = encrypt(myText, pubKey, "RSA/NONE/PKCS1Padding")>

I am not sure how to set the value of pubKey. I have the Base64 encoded modulus and exponent for the 3rd parties Public Key, but I am not sure how to convert the modulus and exponent into the key format that the encrypt() function is looking for.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 09, 2007 Apr 09, 2007

Copy link to clipboard

Copied

my previous post is only an example using the standard encrypt/decrypt using twofish from bouncy castle. The following link ( http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=e546373d) will give you more information on using Bouncy Castle as a security provider.

For PGP, most solutions I've seen use either a custom tag, cfexecute, or possibly the Java route ( http://cephas.net/blog/2004/04/01/pgp-encryption-using-bouncy-castle/)

Hopefully this will give you something to go on.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation