Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
volong
Posts: 4
Registered: ‎06-08-2011
My Device: Storm
My Carrier: Developer

RSA Encryp with Publickey

Dear all,

I am so disapoited now after a long time searching but got nothing to help me resolve this issue.

I have a reference code fo C# now I have to make the same encrypted string with this.

public void ClientCryptoHelper()
{
               string rsaPublicKeyXml = [XML format Key];

               CspParameters cspParams = new CspParameters();
               cspParams.ProviderType = 1; // PROV_RSA_FULL

               cspParams.Flags = CspProviderFlags.UseArchivableKey;
               cspParams.KeyNumber = (int)KeyNumber.Exchange;

               if (string.IsNullOrEmpty(rsaPublicKeyXml))
                              throw new Exception("ClientCryptoHelper has not been initialized with the RSA public key XML");

               // create encryptor
               this.m_rsaProviderEncrypt = new RSACryptoServiceProvider(cspParams);
               this.m_rsaProviderEncrypt.FromXmlString(rsaPublicKeyXml);
}

 

public string EncryptAndConvertToBase64(string toConvert)
{
                return Convert.ToBase64String(this.m_rsaProviderEncrypt.Encrypt(Encoding.Unicode.GetBytes(toConvert), false));
}

Does BB10 Native support this Encryp Method.

Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: RSA Encryp with Publickey

This is the landing page for security and encryption for native BlackBerry 10 developers:

 

https://developer.blackberry.com/native/documentation/core/security.html

 

You probably want to give that a read. It's important to know what you are doing in order to build proper security, otherwise you can be vulnerable to attacks you haven't considered.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.
New Contributor
volong
Posts: 4
Registered: ‎06-08-2011
My Device: Storm
My Carrier: Developer

Re: RSA Encryp with Publickey

thank Paul Bernhardt,

I have ever reseached around this, but found nothing useful.

Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: RSA Encryp with Publickey

What exactly are you hoping to learn? The Security Builder API is quite powerful. https://developer.blackberry.com/native/documentation/core/com.qnx.doc.crypto/topic/c_sb_ug_overview...

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: RSA Encryp with Publickey

Hi Paul,

 

I think what he is trying to say is that the documentation is incredibly scarce and samples non-existant.

Parameters nd functions if explained are confusing to say the least.  The documentation layout is also circulatory in a lot of places.

 

You only have to do a search on these threads to see that the documentation could do with some (read: a lot of) work in this area.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
New Contributor
volong
Posts: 4
Registered: ‎06-08-2011
My Device: Storm
My Carrier: Developer

Re: RSA Encryp with Publickey

Thank BBSJdev, your comment also is my problem, this Document seem lead us around and show out alot of lacked-description-api to use.

I even use this solution, but when I make a double check with C# code, it doesn't work properly, so I think this is not a solution.

With alot of effort, I use this exit way to solve my issue, I just use the javascrip function from this Page, integrate into my QML file, call the encrypt method from .cpp file and receive result through Q_INVOKABLE method. I do not be happy with this, I still research a fully Native-Cascade-Solution.

Thanks all.

 

 

Please use plain text.