开发者

Signing algorithm that works with Android, Java, iPhone, Windows Mobile

开发者 https://www.devze.com 2023-03-11 00:05 出处:网络
Does anyone know of a signing algorithm that will work with all these platforms. The Server will generate an RSA public and private key through a Java Program.The client application (a mobile phone)

Does anyone know of a signing algorithm that will work with all these platforms.

The Server will generate an RSA public and private key through a Java Program. The client application (a mobile phone) will then need to decode a message from the server that is signed using the private key (the public key is stored on the device).

The values below work with Android and Java, however, I am not sure about how they will work with other platforms.

    //For the server signed message
public static final int RSA_KEY_SIZE = 2048;
public static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
public static final Strin开发者_开发百科g RSA = "RSA";
public static final String PROVIDER = "BC"; //Bouncy Castle

    //For hashing sensitive data over the network
public static final String SECURE_RANDOM_ALGORITHM = "SHA1PRNG";


You incorrectly understand asymmetric cryptography. To encrypt message, server should use public key of the client, and with his private key client will be able to decrypt message. What is done with RSA private key is called 'signing'. In case you need to use encryption with only one hard-coded key, you can use symmetric cryptography (for instance, AES).


One of the points of standardised cryptographic algorithms is that they are interoperable, no matter what code was used to implement them. Thus for example RSA-encrypted message can be created by a server written in Java and decrypted by a .Net client (think about how webservers communicate with browsers using HTTPS - there are no restrictions on which languages can you use to write a server/webbrowser).

For Windows Mobile, there's a Bouncy Castle crypto API implementation available (Compact Framework). For iPhone Objective-C code, some reference can be found in this StackOverflow question.

0

精彩评论

暂无评论...
验证码 换一张
取 消