SHA256 implementation for J2ME - blackberry

Please provide the implementation class for SHA256 algoritham in J2ME.I want this encoding to be done in blackberry apps.

Look here http://www.docjar.com/html/api/gnu/java/security/hash/Sha256.java.html
More about SHA-2 (SHA-256/512) are here

Related

Can I decrypt data which is encrypted by Keyczar using Google Tink?

I have been using Google Keyczar for encrypting data in my JAVA app. And I want to change the crypto solution to Google Tink.
But the problem is the already encrypted data by Keyczar. Can I decrypt them by Tink?
If yes, I want to change the crypto solution from Keyczar to Tink. If no, I have to think about another solution.
Thank you.
I did it.
Keyczar is using AES. So I use TinyAES.
Keyczar is also using HMAC. So I use HMAC of avr-crypto-lib.
Just one thing is I have to extract the key from Keyczar key.

Amazon Product Advertising API Signing

I am writing an app on iOS that uses the Amazon API to display a list of products in a category.
The problem I'm having is in signing the API. I am using the advertising API in India, and am using scratchpad to test out the api call.
For the unsigned url generated by Amazon Scratch I have:
http://webservices.amazon.in/onca/xml?Service=AWSECommerceService&Operation=BrowseNodeLookup&SubscriptionId=IAMHIDINGTHISINFO&AssociateTag=HIDINGTHIS-XX&BrowseNodeId=1350388031&ResponseGroup=BrowseNodeInfo
For the signed I have:
http://webservices.amazon.in/onca/xml?AWSAccessKeyId= IAMHIDINGTHISINFO&AssociateTag=HIDINGTHIS-XX&BrowseNodeId=1350388031&Operation=BrowseNodeLookup&ResponseGroup=BrowseNodeInfo&Service=AWSECommerceService&Timestamp=2016-11-21T16%3A06%3A05.000Z&Signature=LETSSAYITGENERATEDTHIS
Following the steps on Amazon's documentation on signing the, I get the final canonical form as:
GET webservices.amazon.co.in/onca/xml AWSAccessKeyId= IAMHIDINGTHISINFO&AssociateTag=HIDINGTHIS-XX&BrowseNodeId=1350388031&Operation=BrowseNodeLookup&ResponseGroup=BrowseNodeInfo&Service=AWSECommerceService&Timestamp=2016-11-20T22%3A55%3A41.000Z
Which is following their steps EXACTLY. I prepend GET\nwebservices.amazon.co.in\n/onca/xml\n to the byte order the rest of the keys and then use HMAC SHA-256 to obtain the signature. Despite this, I get an incorrect signature generated.I know the hashing algorithm I use is correct since when I hash the example that they give in the documentation, it generates the exact hash (I am using AWSSignatureSignerUtility from their iOS SDK).
Can someone please tell me if I should not prepend GET\nwebservices.amazon.co.in\n/onca/xml\n or if it should be something else?
Just figured out the problem with the help of Signed Requests Helper.
Apparently, I was supposed to prepend
GET\nwebservices.amazon.in\n/onca/xml\n
and not
GET\nwebservices.amazon.co.in\n/onca/xml\n

image encrypt/decrypt between php and Android

I want to encrypt an image using PHP and decrypt it in an Android app. I found someone suggest to use MCrypt. However, I noticed that ImageMagick, which I use to convert pdf into jpg, seemed to have ability for encryption. Can I use ImageMagick to encrypt the jpg at the server side and decrypt it using JAVA? Thanks very much.
As per documentation
"ImageMagick only scrambles the image pixels. The image metadata remains untouched and readable by anyone with access to the image file.
ImageMagick uses the AES cipher in Counter mode. We use the the first half of your passphrase to derive the nonce. The second half is the cipher key."
To decrypt the image on the client side, you would have to keep the image header as is and decrypt the remainder of the file using the password with which it was encrypted with. That will require custom coding with knowledge of the image format internals. You will also have to find out how the nonce is derived from the passphrase.
You can alternatively use a SSL connection between the client and server or use any cryptographic scheme available in both PHP and Java either with symetric key or public key encryption as per your requirements.

Creating an RSA private key in iOS

I'm trying to rewrite some Java (Android) code in ObjC on the iPhone. The code will do a basic web service call and needs to set some headers with authentication information.
One part of that information is an encrypted hash of the data I am sending over.
The Java version calculates an SHA256 signature using an RSA private key that is generated on the phone. The private key is generated using a seed that I have available.
The (simplified) java code is as follows:
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
Signature sig = Signature.getInstance("SHA256WithRSAEncryption");
// I get the private key bytes from an outside source
EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
sig.initSign(keyFactory.generatePrivate(privateKeySpec));
sig.update(/* insert my data here */);
return sig.sign();
Now I'm trying to recreate this in iOS and ObjC. Doing the SHA256 signature calculation is easy, but I don't see how to create a private RSA key easily. I would prefer to use the built-in API's if there are any available, but if I must use a third party library like OpenSSL then I can live with that as well.
Most people (citation needed) elect to go with the third party OpenSSL library, not only because rolling your own crypto is hard, but also because their is a good chance you'll create bad crypto if you're not already experienced with it.
That said, nothing prevents you from writing your own SHA256 hash, in straight C or C++ if you like, although I think you'll find your PRNG options lacking and find yourself spending altogether way too much time on entropy pools and the like.
If you do come across a good SHA256 primitive without all the extra baggage of OpenSSL, I'd love to learn about it too! But so far I haven't seen one.

Encryption Registration Number (ERN) or CCATS required for client/server encryption?

I want to encrypt communication between iPhone and my server and I will not use SSL for that. Do I still need ERN or CCATS application for that?
It really depends on what type of encryption you are using. What is the level of encryption? Is it open source?
To see whether you need a ERN, please review the following flowchart:
Flow Chart 2: Classifying under an ECCN in Category 5, Part 2
http://www.bis.doc.gov/index.php/forms-documents/doc_view/328-flowchart-2
The flowchart will help point you in the right direction in the BIS.
This FAQ is helpful too:
http://www.bis.doc.gov/index.php/policy-guidance/encryption/registration

Resources