PKCS5 padding with AES

I use AES encryption, including the huaes.h header. Operating mode is BCE. Encryption and decryption on the device works very well. But I want to send the data encypted to a server using a PKCS5 padding.

How can I configure PKCS5 padding?

Because the API does not provide a way to do this I did it manually.

For everyone else stumble on this issue, I want to share my code that adds the padding. All the code is removed.

QByteArray Cipher::encrypt(QByteArray & plaintext) {
    int moduloBlockSize = plaintext.length() % SB_AES_128_BLOCK_BYTES;
    int plainTextBlockLength = 0;
    if (moduloBlockSize != 0) {
        int nBlockBytes = plaintext.length() / SB_AES_128_BLOCK_BYTES;
        int plaintextBlockBytes = nBlockBytes * SB_AES_128_BLOCK_BYTES;
        plainTextBlockLength = plaintextBlockBytes + SB_AES_128_BLOCK_BYTES;
    } else {
        plainTextBlockLength = plaintext.length() + SB_AES_128_BLOCK_BYTES;
    }
    unsigned char nPaddingBytes = SB_AES_128_BLOCK_BYTES - moduloBlockSize;
    QByteArray plaintextPaddingQByteArray = QByteArray(nPaddingBytes, nPaddingBytes);
    plaintext.append(plaintextPaddingQByteArray);
}

Most of the other cryptographic libraries such as crypto ++ key the default text. Or at least they provide a method to do this.

So I don't really understand why such a common feature is missing in the native API. Perhaps, this should be included in the incident handler?

Tags: BlackBerry Developers

Similar Questions

  • Microsoft L2TP over IPSEC client with AES encryption

    I configured L2TP over IPSec Cisco VPN router with Hastings 3des encryption is sha1 with diffie hellman Group 2 and I can't connect with success of Microsoft customers.

    but my question is why can I not connect when I am increasing the encryption with AES 256 and sha256 DH group 14, his looks that windows does not support advanced encryption.

    is it possiple to activate encryption aes with the highest level...? and how?.

    Hello

    To ensure that you get the best response to your concerns, we suggest that publish this request via the Web to Microsoft Developer network site. To do this, visit this link.

    Best regards.

  • table simple padding with html and dreamweaver question

    0 down vote favorite

    I haven't used DW for awhile, excuse my beginner question.

    I created a table with 2 rows and 1 column in HTML. I inserted an image in the top line and an image on the bottom row.

    With border, Central and spacing between cells set to 0, I can't understand why I see padding/spacing of pixels at the bottom of each cell. I changed the background color of the cells in the red table so that its easy to show the padding.

    Change the vertical alignment to the cells does not change the issue.

    I've not created page CSS to do this.

    From what I remember from my previous experience with DW padding and spacing was quite simple when you create a table of basic HTML, so don't know where I am going wrong.

    Link to the result when I preview the code in safari or chrome

    https://DL.dropboxusercontent.com/u/13258883/DW.PNG

      <!doctype html>
    <html>
      <head>
      <meta charset="UTF-8">
      <title>Untitled Document</title>
      </head>

      <body>
      <table width="512" border="0" cellpadding="0" cellspacing="0" >

      <tbody>
      <tr>
      <td colspan="2" bgcolor="#F50408"><img src="images/Untitled-10_01.gif" width="512" height="107" alt=""/></td>
      </tr>
      <tr>
      <td colspan="2" bgcolor="#F50408"><img src="images/Untitled-10_02.gif" width="512" height="93" alt=""/></td>
      </tr>
      </tbody>
      </table>
      </body>
    </html>

    You suffer from the filling of text-link to images online. Add the css to your external style sheet or in

  • Satellite Z30 - update driver touch pad with adjustable scrolling speed?

    Hello

    touchpad Alps for W8.1 that is currently provided by Toshiba driver doesn't have an option to set the vertical scrolling speed of the gesture two fingers. With the speed by default, even supported the fingers down without moving them results in a scroll that is the equivalent of PAGE_DOWN, for example way to fast. The version I'm using is the most recent site (tpdrv - 20140306120847.zip)

    There is a registry entry in HKEY_CURRENT_USER/Software/Alps/Apoint that make the situation a little more bearable (ScrollLines set to 1), but there is no way to adjust if it more in the settings or the registry

    A newer driver from the Alps (8.103.404.104) from another company has this option and scrolling works as it should on the lowest speed, but it does not support the 2 fingers rightclick.

    Why toshiba is using an outdated driver that is missing this feature critical? Is a new driver available? Anyone find a solution for this?

    Hello

    My knowledge of the laptop manufacturers change and adjust own pilots.
    Driver versions are always different and are not always comparable with versions of driver outputs of other manufacutrers for laptop.

    As you said above:
    published by Toshiba Alps driver does not support the speed of scrolling, but conversely, it supports the right click of 2 fingers.
    The other driver supports scrolling speed option but doesn t support made finger right click.

    It would be nice to have a driver that will support all the options listed.
    So I think that we can just wait and hope that future versions will support some features more nice to have

  • Padding with spaces before update does not

    Hi, I have to insert/update to update a column in ERP which is CHAR NOT NULL.

    In this ERP, if the field is null, it must be filled with spaces

    Example:

    my_field tank (100) not null;

    Thus,.

    When I update this empty data field, it must be:

    update my_table set my_field = rpad(' ', 100)
    
    

    It is a requirement of the ERP. I Don t have control over that.

    I have a form that manage a table of this ERP. In the before INSERT trigger and the datablock UPDATE before I added:

    :my_block.my_field := rpad(nvl(ltrim(:my_block.my_field), ' '), 100);
    
    

    But I always got the error:

    ORA-01407: cannot update ("BAAN"."TTBMTB108100"."T$NOCO$O") to NULL
    
    

    Looks like it's cut the value.

    Work around this problem, I creates a trigger 'before insert or update"where I replace null with space value... but I wonder if he is optioned property or that this either in the forms for it to work as (I think) should be.

    Are there?

    Forms will prune your article, is how forms work. TANK is really something you normally avoid and use VARCHAR2. I understand that you have no control over this.

    So, your table trigger is a solution, or create a trigger to INSERT IT in your form:

    declare

    l_item char (10);

    Start

    l_item: = rpad (nvl (ltrim(:my_block.my_field), ' '), 100);
    insert into my_table (l_item) values;

    end;

  • CF9 encrypted with AES 256 bit, example anyone?

    Hello. I am looking for an example of the Encrypt method using the AES 256 key.  I think I have the unlimited jurisdiction policy files force active.  And I always get the CFError

    The specified key is not a valid key for encryption: illegal key size.

    Now I've hit the wall, can not get.  What harm am I doing?  How can I check that policy files are installed and accessible to my CF file?  Any help is greatly appreciated.

    < cfset thePlainText = "is this work for me?" / >

    Generate the secret key (128): < cfset AES128 = "#generatesecretkey('AES',128) #" / > < cfdump var = "#AES128 #" > < BR >
    Generate the secret key (192): < cfset AES192 = "#generatesecretkey('AES',192) #" / > < cfdump var = "#AES192 #" > < BR >
    Generate the secret key (256): < cfset AES256 = "#generatesecretkey('AES',256) #" / > < cfdump var = "#AES256 #" > < BR > < BR >

    < cfset = AES256 sequence / >
    < cfset theAlgorithm = "AES/CBC/PKCS5Padding" / >
    < cfset theEncoding = "base64" / >
    < cfset theIV = BinaryDecode ("6d795465737449566f7253616c7431323538704c6173745f", "hex") / >

    < cfset encryptedString = encrypt (thePlainText, sequence, theAlgorithm, theEncoding, theIV) / >

    <!--> view results
    < cfset keyLengthInBits = arrayLen (BinaryDecode (sequence, 'base64')) * 8 / >
    < cfset ivLengthInBits = arrayLen (theIV) * 8 / >
    < cfdump var = "" #variables # "label ="Results AES/CBC/PKCS5Padding"/ >"


    < cfabort >

    You probably don't have unlimited jurisdiction policy files to the right place.

    It is very common for admins to think that new policy files go into the directory/lib to usual. But they real go into the directory/jre/security/lib to (unless you're on a Mac, then they go to JAVA_HOME/security/lib).

    You also need to restart once you get in place policy files.

    I tested your script on my local machine, which does not have the policy of unlimited strength and it worked fine.

    Jason

  • Can I use care Microsoft sidewinder & PLAY Game Pad with call of Duty Modern warfare2 c.p.

    At the moment using the mouse & keyboard

    Hello

    Why not?
    The game officially supports gamepads.

    Concerning

  • Integration of ICM with Avaya with AES and CMS

    My client is using Cisco ICM 7 (0) SR3 which is integtrated to an ACD Avaya help EAS and CMS. It's Live for a year, recently they tried to reach officer reason codes is not ready but MHI receives only zeroes instead of the reason code. I was wondering if anyone has experienced this or if there is a setting on the PG or the Avaya which could be changed so that CIM at the front desk officer is not ready codes.

    Hi Klarash,

    Thank you for closing the loop. Please check the question as answered in futures and other persons referred to them.

    Thank you

    / Cedric

  • have a HP Pavilion dv 2913cl XP is OK to put a cd think Pad with Quicken 98 on this computer?

    I'm afraid that if I try to put this on my computer, I could damage it or I don't know how to get the drivers for it?

    Hello

    Sorry, don't understand your question, you want to install Quicken 98 on your HP computer? If so, Quicken 98 should work under Windows XP.

    Kind regards

  • problem with my touch pad

    I have a HP 4520 s. By tapping the button to scroll to the bottom of a document the touch pad locked and an icon appeared with the graph of the touch pad with a slash through it. A little light in the upper left corner of the touchpad is now lit for the first time. Can someone help me to unlock the touchpad?

    Hello

    Press twice on the upper left corner (where the LED is) - this will toggle the touchpad on or off.

    Kind regards

    DP - K

  • Captivate &amp; quot; padding &amp; quot; output with grey window

    I'm working on a project where my "movies" (it is the language of the version 1 of Captivate, I think...) must register in a Flash bodering framework (created by my client) which presents some special controls in this regard. I capture my project to 1010 x 574, to leave room for this adjacent image when end-users watch the result on their screens of 1024 x 768.
    However, the published movie insists on in 1024 x 768 - top, bottom and sides of the window of desired content are padded with gray. that is, there are a gray bar along the top, a gray taller bar along the bottom and thin gray bars on the sides, by filling the frame out to 1024 x 768, even if my captured content is 1010 x 574.

    It is therefore impossible for my client place the film correctly in their Flash of 1024 x 768 frame. First I thought that it would be the HTML code that Captivate generates... but it's actually in the SWF file. my client does not even use the HTML generated by Captivate, they use SWF files directly.

    Last year, we worked on a number of movies using Captivate 1 and we never encountered this problem. (I just re-directed some old movies, to make sure that the problem is not there - it is not.)

    I looked at the different options that are available to me when I "Post", but none of these options seem to solve the problem. (I tried the option "full screen", but which got worse, not better).

    I hope I'm missing something simple here... but can someone give me a clue as to what it could be?
    ---
    PS: I also checked my settings 'Resizing of the project'-'User defined' is selected, with 1010 width and height 574, which is, indeed, what I want - and the percentages are set to 100%. But my result, as I have said, is 1024 x 768 (with grey padding) rather than the 1010 x 574 desired. Makes me say arrgh.

    Another PS: my screen resolution when I captured the screens was identical to the client monitor resolution 1024 x 768, "target." And my capture of 1010 x 574 window was visible (the usual red rectanble) in what I did my capture.

    Hi again

    Certainly what you describe seems to me as if the HTML file is always in the picture. Here's why.

    I created a little movie and put a yellow background.
    Then, I set up the HTML page via the project > skin-> tab borders to be bright blue.
    I then published. As expected, when I launch the application through the HTML page, the film is smaller, bright yellow, centered on a light blue background.
    I then tested by right-clicking the. SWF and choose open with and choose a browser. In this case, Internet Explorer. What I saw when I did it was my film with no bright blue in sight.

    Maybe try the publication with the HTML export option disabled?

    See you soon... Rick

  • Restarting a I - Pad after download

    I've just updated my I - Pad with the latest operating system, as it was pushed to me by Apple.  When I try to reboot the i - Pad, he asks me to go through the clouds.  I tried my Apple ID, but it does not accept it.  I can't access my I - Pad at all.

    poogie1977 wrote:

    I've just updated my I - Pad with the latest operating system, as it was pushed to me by Apple.  When I try to reboot the i - Pad, he asks me to go through the clouds.

    IF you are referring to your iCloud password, have you tried your password Apple ID? You have a different ID to iCloud and iTunes purchases?

  • AES/ebu Audio inputs

    Forum dear friends,

    Today my sound engineer is plugged his Nomad Zaxomm with AES - EBU in my F5.

    The text on the screen side went gray and in the viewfinder, I received the message

    "The AES - EBU input is not Pro-utilisation"

    If anyone has seen this before?

    I run version 3.0 (otherwise I would not have taken the trouble with AES - EBU)

    and last week with a mixer of Cooper with converter separated from AES - EBU everything has worked flawlessly.

    full reset etc. does not change.

    Please let me know your experiences.

    The sound engineer has updated his Zaxcomm Nomad with the latest firmware and now the problem is solved!

    Have not heard of someone overhere having a problem with his camera.

  • Issue of material change: new y710s with numpads?

    Keep in mind that I am well aware hardware mods as this will probably void the guarantee, but this issue is essential to know if I get a y710 or not.

    Here goes:
    I'm really not a fan of the gamezone pad, as a numeric keypad (as was on the former y710s) is infinitely more useful for me, and I'm not left-handed so it does not help the game a lot. But that's just the reason of my question.

    It is, can one replace the gamezone pad with a pad of the 'old' and make it work? And if so, we could get a 'replacement' of Lenovo keypad to do?

    I couldn't find much on the internet for help is very appreciated.

    Probably not... If you buy the Y710 with gamezone, then you're stuck with the gamezone because of the way the motherboard is designed for the Y710s with the gamezone as boost cpu and mini LCD, then the entire upper bezel must be replaced also... more trouble than its worth... the bios most likely is set up with the gamezone in mind too!

  • Problem with re - installation drivers Realtek audio

    I tried to reinstall my Realtek audio drivers, but after restart (after the execution of the application of the establishment) instead of the three drivers Realtek, she just an Audio Bus Audio High Definition and Nvidia High Definition Audio device. I use a Y510p idea Pad with Windows 8 is installed. Does anyone know what is the problem?

    Thanks in advance.

    I used the windows system restore. Sound is back.

Maybe you are looking for