rsa

python RSA implemention with PKCS1

I got the following code in javascript for RSA implementionhttp://www-cs-students.stanford.edu/~tjw/jsbn/: // Return the PKCS#1 RSA encryption of "text" as an even-length hex string function RSAEncrypt(text) { var m = pkcs1pad2(text,(this.n.bitLength()+7)>>3); if(m == null) return null; var c = this.doPublic(m); if(c ==...

Why RSA encryption can return different results with C# and Java?

I using: c#: RSACryptoServiceProvider JAVA: KeyFactory.getInstance("RSA")+Cipher I sending public key (exponent + modulus) as byte array from java to c#. It's ok, there is the same bytes. But when i try to encrypt some data with one key in Java and c# - there is different results. Java Key Generation: KeyPairGenerator keyGen = KeyP...

RSA PKCS1 implementation in Python

I'm working on the RSA PKCS1 implementation in Python,here's the message block i got: m = [0,2,random paddings,0,message integers] I read the RFC2313,and get a equation seems for transforming the message block object into an big-edian integer. I just get confused about how to transform it in Python. Any help would be appreciated. ...

I need to use profiler in my IDE.

Hello I am using RSA7 as IDE, I need to use profiler in my IDE for memory analysis. Can any one suggest me From where I can free download it? How can I use it with RSA7? Many Thanks ...

RSA example that do not use NoPadding

Where can I find a RSA encrypt example that does not use "NoPadding"? --update Better: how to make this SSCCE run correctly without throw the "too much data for RSA block" exception? import java.math.BigInteger; import java.security.KeyFactory; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey...

Loading a RSA private key from memory using libxmlsec

Hello, I'm currently using libxmlsec into my C++ software and I try to load a RSA private key from memory. To do this, I searched trough the API and found this function. It takes binary data, a size, a format string and several PEM-callback related parameters. When I call the function, it just stucks, uses 100% of the CPU time and nev...

RSA Encrypt in PHP to decrypt in .NET

In PHP I am RSA encrypting a message to be decrypted by .NET application... but I keep getting a "Bad Key" exception from .NET.... For RSA encryption, I am using PEAR class Crypt_RSA-> encrypting with the public key (which is a modulus, exponent pair) I get from working encryption system in .NET... I guess the easiest question would be...

Extracting public key from private key in OpenSSL

Hello, I need to extract the RSA public key from a RSA private key using OpenSSL. I'm currently using RSAPublicKey_dup() passing the RSA* private key to get the public key. However, while the call seems to work, I cannot load (or use) this public key using the openssl command-line tool. If I generate the public key using the command-l...

Decrypt file with public key

I have encrypted file and public key. How can I decrypt it from app without installing certificates? file public.key looks like "e+ztydr5GG7saZyrIOtSWGQgHlQbuFn1IVlIIggPIWuLUNTOqN0Y..." Here are some code: NSString* filePath = [[NSBundle mainBundle] pathForResource:@"public" ofType:@"key"]; NSData* publicKeyData = [NSData dataWithCo...

RSA Factorization problem

At class we found this programming problem, and currently, we have no idea how to solve it. The positive integer n is given. It is known that n = p * q, where p and q are primes, p<=q and |q-k*p|<10^5 for some given positive integer k. You must find p and q. Input: 35 1 121 1 1000730021 9 Output: 5 * 7 11 * 11 10007 * 100003 ...

Amazon EC2 RSA key stopped authenticating - Permission denied (publickey)

Authenticating to our Ubuntu EC2 instance worked fine until a little while ago. All of a sudden, the key is being rejected. When we create a new instance with the keypair, we're able to connect to the instance perfectly, so it appears to be an issue with the existing instance. Port 22 is open. Any suggestions on what to look at from a...

Decrypting “long” message encrypted with RSA java

Hi this is the same question, that was asked two years ago: Java/JCE: Decrypting “long” message encrypted with RSA I had a large byte array and rsa keypair, initiated by value 1024. Using rsa encryption and the specified size of the key is strong requirement, I can't change it. So I can't use symmetric encryption with asymetric encrypti...

Is it possible to get RSA private key knowing public key and set of "original data=>encrypted data" entries?

Hi, I work on apllication which allows plugins to access different set of functionality, every plugin provides "initialization string" which sets level of access to different features. Developers send me this strings, and I encrypt them using my 1024 bit RSA private key and send encoded data back. When started, my application decodes enc...

How do I send signed emails from ActionMailer?

I'm using GMail as my SMTP server. I have that configuration working just fine: # config/initializers/action_mailer.rb: ActionMailer::Base.smtp_settings = { :tls => true, :address => "smtp.gmail.com", :port => "587", :domain => "www.example.org", :authentication => :login, :user_name ...

Java RSA Encrypt using .NET XML Key File - need help

In .net I have generated the following public key file: <RSAKeyValue> <Modulus>xTSiS4+I/x9awUXcF66Ffw7tracsQfGCn6g6k/hGkLquHYMFTCYk4mOB5NwLwqczwvl8HkQfDShGcvrm47XHKUzA8iadWdA5n4toBECzRxiCWCHm1KEg59LUD3fxTG5ogGiNxDj9wSguCIzFdUxBYq5ot2J4iLgGu0qShml5vwk=</Modulus> <Exponent>AQAB</Exponent> .NET is happy to encrypt using it's normal met...

Java RSA Encrypt - Decrypt .NET - need help

I am encrypting on JAVA using RSA and attempting to decrypt using .NET. I am including my JAVA code and .NET code in hopes that someone has some experience with this sort of thing. JAVA Code: byte[] modulusBytes = Base64.decode("xTSiS4+I/x9awUXcF66Ffw7tracsQfGCn6g6k/hGkLquHYMFTCYk4mOB5NwLwqczwvl8HkQfDShGcvrm47XHKUzA8iadWdA5n4toBEC...

PHP's openssl_sign generates different signature than SSCrypto's sign

I'm writing an OS X client for a software that is written in PHP. This software uses a simple RPC interface to receive and execute commands. The RPC client has to sign the commands he sends to ensure that no MITM can modify any of them. However, as the server was not accepting the signatures I sent from my OS X client, I started investi...

Problem with RSA-encrypting a string in PHP and passing it to .NET service

I need to call a web service that requires a login url containing an RSA encrypted, base_64 encoded and url-encoded login data. I don't have a formal php training, but even for me it seems like an easy task, however when calling the service I get an 'Invalid Format' response. What am I doing wrong and is there another way to come up with...

RSA encrypted Diffie-Hellman handshake

Would a RSA encrypted Diffie-Hellman handshake enable secure communication? I'm encrypting communication from a silverlight client to a php webservice. The silverlight client initiates they key agreement by sending the RSA public key encrypted DH parameters to the webservice. Only the webservice has the private key, so a MITM attack is n...

Implement a RSA algorithm in Java

Hello everyone. I want to implement a RSA algorithm to encrypt an image (byte[]). To generate my two keys I used this piece of code : KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA"); keygen.initialize(512); keyPair = keygen.generateKeyPair(); Once public and private key are generated, I would like to show them to the us...