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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido
Accepted Solution

AESCryptoDemo strength question.

I want to use 256bits AES encryption.

 

In the AESCryptoDemo DRBG.cpp file function

 

DRBG::DRBG(GlobalContext & gc) :
   Crypto("DRBG"), context(gc), rngCtx(NULL) {
   int rc = hu_RngDrbgCreate(HU_DRBG_HASH, 112, false, 0, NULL, NULL, &rngCtx,
context.ctx());
  maybeLog("DRBGCreate", rc);
}

 

To change to 256 bits encryption do I just change 112 to 256?

 

do I also need to change in the UI app

 

QString ApplicationUI::generate() {
DRBG drbg(globalContext);
QByteArray buffer(16, 0);
int rc = drbg.getBytes(buffer);
if (rc != SB_SUCCESS) {
toast(
QString("Could not generate random bytes %1").arg(
SBError::getErrorText(rc)));
return "";
}
return toHex(buffer);
}

 

to

 

QByteArray buffer(32, 0);

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: AESCryptoDemo strength question.

What you have suggested pretty much matches what the documentation says will happen:

http://developer.blackberry.com/native/reference/core/com.qnx.doc.crypto.lib_ref/topic/manual/about_...

 

Just to confirm, you are aware that this is just generating a random sequence of bytes?  As I understand it, by changing from 112 to 256, you just make it more likely the created data is random. 

 

"do I also need to change in the UI app"

 

Not as far as I can tell- all changing the length of buffer will do is change how many bytes you get back, that is not related to the security settings for the random number generator. 

Highlighted
Developer
Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: AESCryptoDemo strength question.


peter_strange wrote:

Just to confirm, you are aware that this is just generating a random sequence of bytes?  As I understand it, by changing from 112 to 256, you just make it more likely the created data is random. 



So what makes the app to use 256bits encryption?

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: AESCryptoDemo strength question.

Hi,

 

Changing DRBG changes the expected quality of the DRBG.

 

The second part, where you're changing the length is the part that will make AES 256 happen.

 

ie:

  DRBG tweak => goodness of key

  Key size change => AES256...

 

 

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: AESCryptoDemo strength question.


robbieDubya wrote:

Hi,

 

Changing DRBG changes the expected quality of the DRBG.

 

The second part, where you're changing the length is the part that will make AES 256 happen.

 

ie:

  DRBG tweak => goodness of key

  Key size change => AES256...

 

 



Does this need changing to 32 size for 256bits?

 

    QByteArray buffer(16, 0);
    int rc = drbg.getBytes(buffer);

 

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: AESCryptoDemo strength question.

Yes, that is the key. (This is what I was referring to as changing the key size).

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: AESCryptoDemo strength question.

[ Edited ]

I have changed the following

 

    int rc = hu_RngDrbgCreate(HU_DRBG_HASH, 256, false, 0, NULL, NULL, &rngCtx,
            context.ctx());

    QByteArray buffer(32, 0);
    int rc = drbg.getBytes(buffer);

and now when I call encrypt I'm getting this error

 

Crypto operation failed. SB_ERR_BAD_IV_LEN (59400)

 

these are the keys size 32 hex encoded

 

Debug: key "8c0fa89b1cd6289175f711ffc6d8a856e4f66b69ddbcf7c660cd5c4ac4225d65"
Debug: iv "ccf48494c11f2982f0b118b665411f768568f5404cce20755c159f9856adf843"

 

 edit: I found the problem.  the iv key size was incorrect as the message indicated. do not use the iv.length() when you encrypyt or decrypt.  use SB_AES_128_BLOCK_BYTES instead.  the AESDemo should be corrected.

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: AESCryptoDemo strength question.

[ Edited ]

Oh yes - only the key has to change size - not the IV. (IV must stay at block size).

 

I have a bunch of changes planned for the demo... The community is open... Smiley Wink

 

ie: you should use iv.length() - just have to make sure the iv is the correct length. (easy way to lead to memory corruption to NOT be using the length of the buffer you're referring to...)

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: AESCryptoDemo strength question.


robbieDubya wrote:

Oh yes - only the key has to change size - not the IV. (IV must stay at block size).

 

I have a bunch of changes planned for the demo... The community is open... Smiley Wink

 

ie: you should use iv.length() - just have to make sure the iv is the correct length. (easy way to lead to memory corruption to NOT be using the length of the buffer you're referring to...)


OK. Thanks