FAQ Database Discussion Community


CryptographicException (The parameter is incorrect) on Windows 8.1 but not Windows 7

c#,cryptography,windows-8.1,rsa
I have some code that's been working fine on Windows 7 but fails now that I've started using a Windows 8.1 dev box (see repro code below). Is RSA different on Windows 8.1 vs. Windows 7? using System.Security.Cryptography; using System.Text; namespace RsaBug { class Program { static void Main() {...

Implement same RSA encryption on iOS and Android

android,ios,encryption,rsa
I have iOS sources for data encoding and I try to implement same encoding in Android app. iOS sources: - (NSString *)encryptRSA:(NSString *)plainTextString useKeyWithTag:(NSString *)tag withSecPadding:(SecPadding)padding { SecKeyRef publicKey = [self _getPublicKeyRefByTag:tag]; size_t cipherBufferSize = SecKeyGetBlockSize(publicKey); uint8_t *cipherBuffer = malloc(cipherBufferSize); uint8_t *nonce = (uint8_t *)[plainTextString UTF8String]; SecKeyEncrypt(publicKey, padding, nonce, strlen(...

Segmentation fault when trying to use EVP functions in OpenSSL

c++,encryption,openssl,rsa,envelope
I am trying to do public encryption with OpenSSL using RSA and its high-level envelope functions. However I cannot seem to get my head around them and I'm getting a segmentation fault. This condensed code from my project reproduces the problem: #include <iostream> #include <string> #include <openssl/evp.h> #include <openssl/pem.h> #include...

Can't set public/private key in OpenSSL

c++,c,encryption,openssl,rsa
I am trying to set the public and private key to an EVP_PKEY in C++ from a string. However, even after following several examples online, the PKEY always comes out as NULL. Here is the code to reproduce the problem (this is for private keys but the effect is the...

Showing Values in JFrame

java,swing,encryption,rsa
I have been playing around with the RSA algorithm and JFrame. I am struggling to figure out how to print the output in the JFrame and not in the console. When the program runs the user enters a string and clicks submit which is then encrypted and decrypted and the...

Using Security Transforms to verify an RSA signature created with Ruby/OpenSSL

ruby,cocoa,openssl,licensing,rsa
I'm trying to implement a simple license key scheme for my app and I'm running into significant roadblocks. I'm following the example at OpenSSL for License Keys. Since that blog post was written in 2004 and OpenSSL has been deprecated on OS X I'm attempting to use the Security Transforms...

Work out co-prime of two numbers in java

java,cryptography,rsa
I have two BigIntegers holding prime numbers. BigInteger a = BigInteger.probablePrime(16, new Random()); BigInteger b = BigInteger.probablePrime(16, new Random()); BigInteger c; How would I find the co-prime of these two BigIntegers and store it in c;...

How to perform RSAES-OAEP encryption and decryption using .NET Framework?

.net,cryptography,rsa,encryption-asymmetric
The question is fairly straightforward - is RSAES-OAEP possible with the built-in cryptographic primitives? If not, is a 3rd party library such as BouncyCastle able to provide such functionality? The purpose of this is to encrypt a 256-bit AES key....

Signing and verifying with java android

java,android,rsa,digital-signature,public-key-encryption
I'm trying to sign an encrypted message with a private key and verify it in Java. This is my first time working with encryption and signatures so I'm not sure how it is supposed to work and I'm kind of stuck here. The verification always returns false. I am posting...

Why this js code's RSA encrypted result is different from java's RSA standard code?

java,javascript,encryption,cryptography,rsa
Here is javascript code named Barrett. It can do RSA encryption and I put it into code snippet: /* * RSA, a suite of routines for performing RSA public-key computations in JavaScript. * Copyright 1998-2005 David Shapiro. * Dave Shapiro * [email protected] * changed by Fuchun, 2010-05-06 * [email protected] */...

Export massage that encrypted with python-rsa

python,encryption,rsa
I use this code to create public and private keys: import rsa (pubkey, privkey) = rsa.newkeys(512) And then convert it to PEM format: exppub =pubkey.save_pkcs1(format='PEM') exppriv = privkey.save_pkcs1(format='PEM') When i encrypt massage with this keys: message = 'hello Bob!' crypto = rsa.encrypt(message, pubkey) encrypted massage is like this: "@\xc4\xb2\x14r\xf1x\xb8\xb2\t;\x9a:\x1dl\x11\xe2\x10\xa9E\xee\x8b\xac\xd0\xd3Y\xfb}\xd9@\xdd\x0c\xa5\xd2\xfc1\xd6\x06\xf0\xb8\x944\xe1\xc2r\xe5anyq\xac\xdfh\xeb\x10\x80\x98\xa1\xee'\xe6hpi" and...

RSA Decription fails due to input string

java,encryption,rsa,badpaddingexception
I have the following problem. I have 2 functions in my code which are intended to encrypt / decrypt simple string. SO: I have to pass a string "someString" to the function: public static String doEncryption(String input) { try { if (!RSAService.areKeysPresent()) { RSAService.generateKey(); } ObjectInputStream inputStream; // Encrypt the...

Computing private key of a user from his RSA public key

security,encryption,cryptography,rsa,public-key-encryption
I know that we will give (N,e) as our public key to every one and N is product of two prime numbers P and Q. But I know that product of two prime numbers has only 4 divisors (1, itself, P, Q) and using a simple while loop hackers can...

C# AES and RSA File Encryption - How to use IV?

c#,encryption,cryptography,aes,rsa
I'm writing a program at the moment that works under the following scenario: I've got some confidential log files that I need to backup to a server. I have a program that generates these log files every day. These log files would rarely if ever need to be opened. I...

extracting public key from private key dynamically using M2Crypto

python,rsa,m2crypto
is it possible to extract public key from private key in pem format in python, with something like M2Crypto? I want to same thing happen like when you use this command: openssl rsa -in mykey.pem -pubout > mykey.pub ...

Trying to understand RSA encryption code example

java,encryption,cryptography,rsa
I'm trying to understand this piece of code but I can't get it around my head. So the program is taking in a value and using "RSA" algorithm to encrypt it the inputted value. What I don't understand is the bytesToString part of the code. Is the program converting the...

An exception of type 'System.Security.Cryptography.CryptographicException': keyset does not exist

c#,encryption,cryptography,rsa,x509certificate
All the steps made at this link System.Security.Cryptography.CryptographicException: keyset does not exist But it did not help to correct the error. static public string Build64(string idOrder, double Amount) { string StrForSign = KKBRequestStr.Replace("%ORDER%", idOrder).Replace("%AMOUNT%", string.Format("{0:f}", Amount).Replace(",", ".")); X509Certificate2 KKbCert = new X509Certificate2(KKBpfxFile, KKBpfxPass); RSACryptoServiceProvider rsaCSP = (RSACryptoServiceProvider)KKbCert.PublicKey.Key; byte[] SignData =...

invalid private key on decrypt data in PHP

php,encryption,openssl,rsa
I am trying to decrypt the private key data in PHP. But my response displays the private key invalid. I tried a lot of other options but dont helping. To start I need at least the most simple example of how to decrypt the data in PHP. My code: $privateKey...

Rsa algoritmn generates ? characteres in java

java,android,security,rsa
I'm making an Android app for sending safe sms. I currently have the following code (Iam using 256 for testing) public void generateKey() throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException,BadPaddingException,InvalidKeyException{ try{ kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(256); kp = kpg.genKeyPair(); }catch(Exception e){ e.printStackTrace(); Toast.makeText(getBaseContext(), e.toString(),Toast.LENGTH_LONG).show(); } } public byte[] RSAEncrypt(final String plain) throws...

RSA encryption in Android and Java

java,android,security,encryption,rsa
I would like to encrypt a String with RSA encryption. My public/private keys were generated and stored in DB. In android, I use this code: public static String encryptRSAToString(String text, String strPublicKey) { byte[] cipherText = null; String strEncryInfoData=""; try { KeyFactory keyFac = KeyFactory.getInstance("RSA"); KeySpec keySpec = new X509EncodedKeySpec(Base64.decode(strPublicKey.trim().getBytes(),...

phpseclib loadKey works on mac, not on CentOS

php,centos,rsa,phpseclib
I am attempting to load a hardcoded (for the sake of testing) RSA public key in phpseclib (stable version 0.3.10). This code works perfectly correctly when run locally on my Mac and spits back out the key I entered: CONST PUBLIC_KEY = '-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYwTO/CJJQ8vbwTRQRWmOS0Pbz tFCks4RhmPxYANSQV5V9Qy+QSupewn2WAb7zV04r4RqtwxB7stDMbK+uPY+GYR5M moQuT0YStJ6TXJjiF8i1Y+DBGLnTXOD36y93V8DpuFWMxMYtROskE+Mx1W70+VTZ EM6k+jvIfzRJoVDqswIDAQAB -----END...

Import CSP blob exported from .NET into python pyCropto

python,.net,rsa,pycrypto,cryptoapi
I have a CPS Blob exported from certificate using RSACryptoServiceProvider.ExportCspBlob in my .NET application. return Convert.ToBase64String(rsaAlg.ExportCspBlob(false /*includePrivateParameters*/)); Now, I need to import that blob in python application. I tried using pyCrypto, but with no luck. # that's the value I'm getting from .NET code above key =...

Difference between results with RSA Encryption with Bouncy Castle in Java and C#

java,c#,encryption,rsa,bouncycastle
I have a Java working sample app (which uses Bouncy Castle) that I need to port to C# (I'm using Bouncy Castle for C# too). The code is almost the same. However, even when I provide exactly the same modulus and exponent for both, the result arrays are completely different...

RSA Encryption Error

java,encryption,rsa
I have generated a public and private code with puttygen, the private key is exported as openssl, the name of the peys are public_key.der , private_key.pem but when i try to use java to encrypt it i get this error: java.io.FileNotFoundException: public_key.der The codode is : public static String RSAPublicEncryptuion(String...

Android Base64 Encoding and Apache codec decoding

java,android,encryption,base64,rsa
We are using following method for encoding a string using ANDROID Base64.NO_CLOSE public static String encrypt(String inputString, byte[] keyBytes) { Calendar cal = Calendar.getInstance(); int mDay = cal.get(Calendar.DAY_OF_MONTH); // System.out.println("Day of month :::" + mDay); String encryptedString = ""; Key publicKey = null; try { Random generator = new Random(mDay);...

Private key length > public key?

encryption,rsa,privatekey,public-key
I'm working on rsa private and public key / encryption / decryption / etc using openssl module. But a question is still unanswered : why private key are often (are always, i don't know) longer than public key ? Is there several answer to this ? This is my public...

Source text, key size relationship for encryption/decryption in Go

encryption,go,cryptography,aes,rsa
In the code below (also at http://play.golang.org/p/77fRvrDa4A but takes "too long to process" in the browser there) the 124 byte version of the sourceText won't encrypt because: "message too long for RSA public key size" of 1024. It, and the longer 124 byte sourceText version, work with 2048 bit key...

Breaking RSA given we know minimal solution to discrete log mod N [closed]

math,rsa,public-key-encryption,modular-arithmetic
So I'm trying to figure out the connection between the discrete log problem and RSA. I think this is what the following question is trying to do. Suppose you have an oracle which gives you the smallest positive x satisfying the following congruence: g^x ≡ k (mod N) where N...

Android: BadPaddingException while decrypting RSA from other client

java,android,encryption,cryptography,rsa
So, I'm writing an Android application for my practicum, that broadcasts its RSA public key to the network, and allows other clients to connect to it via TCP. From there, I have my own custom protocol and packet structure, which I then encrypt and send to the client (packet ->...

How to correct generate signature using rsa private key with java?

java,soap,cryptography,rsa,jks
I'm new in crypto with Java and I have a simple question. I have JKS keystore with SHA1withRSA trusted private key and certificate and I need to generate PKCS#7 signature for SOAP message. I tried found some info about this and at the moment, I have this: KeyStore ks =...

Load RSA public key created in JSBN, then encrypt a message

javascript,c++,encryption,rsa,crypto++
I am trying to create a RSA key pair in JavaScript using JSBN and transfer the public key to Crypto++. Then, I am trying to encrypt a message in Crypto++ and send it back to JavaScript and decrypt it. But I am relatively new at this, so I think I...

Decrypting RSA with MIHCrypto (OpenSSL-Universal on iOS)

ios,objective-c,encryption,rsa
Hi I've got the a Problem with decrypting using MIHCrypto v0.3.2. These are my lines of code: NSString *encrypted_text = @"BdhFH0sd7e9DExiCd50Ykh4spm2BX126skjJ1o8HHjKsN+J7r9IoI9kbB9AAacEpJsAfyesiJsq5gDBhQtcNbB6l88aSgPrEoVwR9ilzuzVcv1q3J1dxs4uIEMuhzoWT+R8//dD2jDdXPyFsdGWJc10CEizPFKpmy2jWhvU8CVs="; NSBundle *myBundle = [NSBundle mainBundle]; NSString *privateKeyPath= [myBundle pathForResource:@"rsa_1024_priv" ofType:@"pem"]; NSData *privateKeyData = [[NSFileManager defaultManager] contentsAtPath:privateKeyPath]; MIHRSAPrivateKey...

Android NullPointer Exception in method kpg.initializate

java,android,security,rsa
I'm a newbie in android and I'm trying to make a "simple" tutorial about a cypher/decypher application. I've the following code public class MainActivity extends AppCompatActivity { KeyPairGenerator kpg; KeyPair kp; PublicKey publicKey; PrivateKey privateKey; byte[] encryptedBytes, decryptedBytes; Cipher cipher, cipher1; String encrypted, decrypted; @Override protected void onCreate(Bundle savedInstanceState) {...

How to extract public key from a .Net DLL in C#? [duplicate]

c#,.net,rsa,cryptoapi
This question already has an answer here: How do I read the public key from a signed C# exe 2 answers I want to extract public key, not public key token, in C# from a autenticode signed .Net DLL?...

Error with encrypt message with RSA python

python,python-3.x,encryption,rsa
Use the sample code to encrypt a message using the RSA, but I get the following error. Traceback (most recent call last): File "E:/PythonProjects/skypy/skypy/codebase/utils/crypto.py", line 32, in <module> print(RSAPubKey.encrypt("Hello.", 32)) File "E:\Programs\Python3.4\lib\site-packages\Crypto\PublicKey\RSA.py", line 150, in encrypt return pubkey.pubkey.encrypt(self, plaintext, K) File "E:\Programs\Python3.4\lib\site-packages\Crypto\PublicKey\pubkey.py", line 75, in encrypt ciphertext=self._encrypt(plaintext, K) File...

Get RSA keys in a “simple” form

c++,c,encryption,openssl,rsa
How can I get keys generated by OpenSSL in RAW form? I mean I can't decode my encoded messages in any of online tools. What actions should I do to distribute my keys to other clients (in other apps and web-apps) in proper forms? My generation code is: void VS_CarrierNet::generateKeys()...

Generating e value in RSA Encryption

c++,encryption,rsa
I've generated p,q,n, and totient, and need to generate e where 1 < e < totient and e and totient are coprime. The problem I'm running into with my code is that I'm first generating totient (normal (p-1)*(q-1) way) but when i try to generate a coprime e, it usually...

RSA key pair generator applet, generate fixed almost zero private and public keys

java,rsa,javacard
I wrote the below JavaCard applet to generate 512 bit RSA public and private key pairs on the card and transfer them through the APDU responses to the outside: public class CryptoRSA extends Applet { //Abbreviations private static final boolean NO_EXTERNAL_ACCESS = false; //arrays for generated keys in byte. (I...

Inconsistent RSA signature across platforms

c#,php,cryptography,rsa,phpseclib
I'm creating a license key generator that RSA signs base64 encoded license key data and appends signature to license data.On the end user side signature is verified using the public key that is bundled with application.We have applications running on .net, php, java, and other platforms.License model should be same...

How to find m in c = m^e (mod n) if c, e, n are known

language-agnostic,rsa,number-theory,modular-arithmetic
Suppose I have known java BigIntegers c, e, and n, is there a way to quickly calculate the BigInteger m, where: c = m^e (mod n) ...

How to download cookbooks from supermarked with deps?

rsa,chef,knife
I need to download some cookbooks. They have a lot of dependencies. I've machine with knife & chef installed. I want just to download public cookbooks. When i execute knife cookbook download git i get following error: ERROR: Your private key could not be loaded from /home/vagrant/.chef/vagrant.pem Check your configuration...

iOS SecKeyEncrypt OAEP SHA512

ios,encryption,hash,rsa
From what I can tell looking through the various padding values for the SecKeyEncrypt method in Apple's security framework, it does not support OAEP padding with a SHA512 hash digest. In fact, I can't seem to determine if the SecKeyEncrypt method does any sort of hashing/masking of each block during...

Using ursa (nodejs module) to generate a symmetric key?

node.js,encryption,rsa,encryption-symmetric
I'm using ursa (nodejs module) to do the following: Use a private key and someone else's public key to generate a symmetric key Encrypt some data with the symmetric key Encrypt the symmetric key with the user's public key However, I can't seem to find any methods that allow me...

How to ignore or Pass 'Yes' when The authenticity of host can't be established in Expect Shell script during Automation

shell,automation,rsa,expect,host
I want to Provide 'Yes' automatically or Ignore it and proceed in a SECURE way, when the below statement comes during execution of my Expect Shell script?. #!/usr/bin/expect spawn ssh $user@$host The authenticity of host 'abcdef (10.566.1.98)' can't be established. RSA key fingerprint is jk:94:ba:93:0b:eb:ff:df:ea:gh:hj:23:3c:hj:9c:be. Are you sure you want...

Falcificate X509 signature

cryptography,openssl,rsa
Suppose we have two x509 certificates - client and server. Is it possible to change some fields of client certificate (CN for example) and recalculate signature using server's public key (wich is known) in such a way that server will accept and successfuly verify client certificate? In public key cryptography...

C# RSA Public Key Output Not Correct

c#,openssl,rsa,public-key,pem
I am currently trying to generate and send a public RSA key using C#. It should be a 2048 bit long key in PEM format. I have successfully done so using OpenSSL command with the following (some output are shortened): $ openssl genrsa 2048 Generating RSA private key, 2048 bit...

Decrypt string using the pem or pkcs key received in c#

c#,encryption,rsa
Given the key in pem format similar to -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,DE1BB301BDE4BB45 msUEpZKZ0uaOmhGXBPnh2GoNSXyExdeqETd9w71l0G1bk1cCbiV4EOnmR7bcN+OE (20 lines) YoIx/E+tFHkt3gQcFhVUNgSOe/5+huXwRwUC5dthPzzZFlDCXHfwfrrBzOSGxZpX uBs1JxY4qOLRdZVaZlQespForxBTYD6RuHi1UI5lqEW7363VyCLho9QYgGFM0LUi qbln5WV37PTmayxMfzlGUB2XazwON+WU3obbXuCFXAy96Y6VGzv0lQ== -----END RSA PRIVATE KEY----- And the encrypted string(which was encrypted using the public key) I tried to decrypt with the following code...

RSA BadPaddingException in Java - encrypt in Android decrypt in JRE

java,android,encryption,rsa,badpaddingexception
i found some other questions but i did not find a explaination what causes this. I wrote a function in Java to encrypt data, store it into a file and decrypt it loading the file again. As it is a asymetric encryption, i have a public and a private key...

Difference between Sha1WithRSA and Sha1WithRSAEncryption?

java,rsa,digital-signature,sha1,public-key-encryption
I've noticed these two algorithms that have different names, but functionally sound very similar. When I looked further, I've found out Sha1WithRSA is available across many Security Providers, but Sha1WithRSAEncryption is only available if I use the BouncyCastle Provider. Example: JcaContentSignerBuilder("SHA1WithRSAEncryption").setProvider("BC") Is it replacable with JcaContentSignerBuilder("SHA1WithRSA").setProvider("SunJSSE") ? Can someone throw...

SSL Cipher help in C

c,sockets,ssl,https,rsa
I am trying to Use SSL on top of tcp/ip to send an HTTPS request to a site using C. I have no access to curl or other standard libraries. Pretend like i can't load any libraries at all. I need to set an SSL Profile Cipher. When I successfully...

How would I load a Private / Public Key from a string / byte array or any other container

c++,cryptography,rsa,public-key-encryption,crypto++
Is it possible to store a RSA Private/Public Key in the source for example in a byte[] or string or any other container and use this key for encryption / decryption? A decode function from file would look like: void Decode(const string& filename, BufferedTransformation& bt) { // http://www.cryptopp.com/docs/ref/class_file_source.html FileSource file(filename.c_str(),...

Getting RSAPublicKey From File With Extension pem

java-ee,rsa,public-key-encryption,public-key,pem
I am trying to implement Paybox Payment Gateway integration to my application. After payment Paybox returns me a signature and I have to verify it. I have test keys provided by Paybox, 'TestK004.prv.pem' and 'TestK004.pub.pem'. Here is my Test Class: package com.alpha.shop.component.payment.methods.crc.impl.ww.paybox; import java.security.interfaces.RSAPublicKey; import java.security.Signature; import java.security.KeyFactory; import java.security.spec.X509EncodedKeySpec;...

Convert CRYPT_RSA_PUBLIC_FORMAT_PKCS1 from php to RSA Public key in Java

java,php,android,rsa,phpseclib
I'm trying to send a RSA Public Key from PHP to Java(Android). My PHP code looks something like this: function __construct() { $rsa = new Crypt_RSA(); $rsa->setHash('sha1'); $rsa->setMGFHash('sha1'); $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_OAEP); $rsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1); $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1); // Code to Generate the public key and private key $keys = $rsa->createKey(1024); extract($keys); // Base 64 encode Public...

Verify RSA sign with 512 bit public key in C#

c#,rsa
I used following code to convert X.509 public key to C# RSAParameters which works good with 1024 bits key. But for 512 bits key, rsa.VerifyData(data, new SHA1CryptoServiceProvider(), sign) return false. I had verified sign, data with the public key in Java it's correct. byte[] keyBytes = Convert.FromBase64String(publicKeyString); byte[] modulus; switch...

CryptoAPI - how to extract RSA public key from private

rsa,public-key-encryption,cryptoapi,encryption-asymmetric
Using windows CryptoAPI, is it possible to get public RSA key from a private key which was imported (not generated)? If I use CryptGenKey, I can call CryptExportPublicKeyInfo and CryptImportPublicKeyInfo to obtain the public key handle. However, when I try to do the same thing with private key decoded from...

Bouncycastle - Native RSA vs. RSA

java,encryption,rsa,bouncycastle
There are two different ciphers in the Bouncy Castle crypto library that you can pass to PKCS1Encoding: NativeRSAEngine and RSAEngine. Is there a difference between these two variants? Edit: As Maarten pointed out in his comment, NativeRSAEngine is not part of the Bouncy Castle library itself; it is an addition...

Decryption Error bad padding

java,encryption,rsa,badpaddingexception
I am trying to send encrypted messages between two agents .I have a string that contains information that I convert to bytes encrypt it and then to string again to send the message. Messages are received however, at the receiving agent I get the following exception javax.crypto.BadPaddingException: Decryption error at...

Python RSA Brute Force Check

python,encryption,cryptography,rsa,brute-force
I have an exercise to brute force a piece of text that has been encrypted with a very small key. The public key I have is (e = 5, n = 203). The text has been converted to ASCII, shifted a fixed number and then encrypted with the RSA public...

Segmentation fault with generating an RSA and saving in ASN.1/DER?

c,openssl,cryptography,rsa
#include <string.h> #include <openssl/aes.h> #include <openssl/rand.h> #include <openssl/bio.h> #include <openssl/rsa.h> #include <openssl/evp.h> #include <openssl/pem.h> #define RSA_LEN 2048 #define RSA_FACTOR 65537 int genRSA2048(unsigned char **pub,unsigned int *pub_l,unsigned char **priv,unsigned int *priv_l){ RSA *pRSA = NULL; pRSA = RSA_generate_key(RSA_LEN,RSA_FACTOR,NULL,NULL); if (pRSA){ pub_l = malloc(sizeof(pub_l)); *pub_l = i2d_RSAPublicKey(pRSA,pub); priv_l = malloc(sizeof(priv_l));...

Decryption with RSACryptoServiceProvider fails

c#,encryption,key,rsa,biginteger
I want to decrypt a byte array. to do this, I encrypt the data in java with the servers public key. Then I send the data to the c# server. There I want to decrypt with the "RSACryptoServiceProvider" class. I initialize it with: RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024); rsa.ImportParameters(keyInfo); The...

RSA private Key decryption giving “InvalidCipherTextException” using bouncy castle

java-me,rsa,bouncycastle
I am creating a encryption/decryption method using bouncy castle for j2me. I have created private / public keys using openssl and hard coding into the code. Encryption is working fine (I am getting encrypted string), but when I try decryption for that ciphertext I am getting below exception org.bouncycastle.crypto.InvalidCipherTextException: unknown...

Get access to REST API using JWT security token

java,rsa,token,jwt
I have RSA key in format <RSAKeyValue> <Modulus> ..</Modulus> <Exponent>..</Exponent> ... </RSAKeyValue> I need to get connection to REST API using java. I should use JWT security token with schema “TokenIssuer”. Nimbus library provide following example for doing it. Will it help me or I need something else? If yes,...

Android Save RSA Private and Public Key

java,android,rsa,android-keystore
I need to save my RSA private and public key. Here I create it. KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(1024); KeyPair kp = kpg.genKeyPair(); publicKey = kp.getPublic(); privateKey = kp.getPrivate(); Now I want to use both keys the next time. So they should be stored on the device. byte[] publicKeyBytes =...

Send RSA Public Key in Java to PHP server

php,android,encryption,rsa,phpseclib
I'm having trouble trying to convert a Java generated RSA Public KEY to string format so I can use it on the PHP side. I tried converting it to string but the encryption fails on the PHP side. I generate a public Key in Java like this: KeyPairGenerator k =...

Generating RSA public key from byte array

java,rsa,bouncycastle
I am having some trouble generating a RSA public key object. In this method, I read e (exponent) and n (modulus) from a file into two byte arrays. I want to use those two byte arrays to create a RSA public key object. Unfortunately, in my implementation, I get an...

Nexus 7 shows offline under adb linux

android,linux,adb,rsa
I just got my Nexus 7 today, and I am trying to root it using adb. It always shows my nexus as offline. I have tried updating my adb (It is version 1.0.31) I do have usb debugging enabled, I have tried reconnecting it to different usb ports. It has...

node.js crypto signature and openssl signature does not match

node.js,openssl,rsa,digital-signature,sha256
I wanted to perform RSA-SHA512 on a file in node.js. I could calculate sha512 hash of the given data file which matches with that of openssl's. However when trying to get the digital signature on the same hash, node.js signature differs from openssl signature. Below is an example code snippet:...

Best way to store private crypto key in browser?

javascript,web-applications,cryptography,rsa,token
I would like to encrypt some user data before it's sent to the server. That is, the data will be encrypted on the client side in browser using JavaScript. My question is, what options are available for storing private keys on the client side (it will be used for decrypting...

BigInteger implementation of RSA's key generation

java,rsa,biginteger
I am having a bit of trouble getting the modulus's size to be consistently 128 bytes big. Sometimes the modulus's byte array has a size of 129 or even 130. I've searched for implementation online, and my implementation is really close to the one from this link: http://introcs.cs.princeton.edu/java/78crypto/RSA.java.html Here is...

RSA decrypt on android lollipop

ssl,rsa,android-5.0-lollipop,android-4.4-kitkat,public-key
I have an error with decryption with RSA. The code works on android 4.4 kit kat, but the same app doesn't work on android 5.0 lollipop. KeyFactory keyFactory = KeyFactory.getInstance("RSA"); RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(new BigInteger(modulusBytes), new BigInteger(exponentBytes)); RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec); byte[] decrypted = null; try { //...

How to get public RSA key from unformatted String

java,rsa
I have an unformatted public key in a properties file, meaning it only contains the public key hexa value: K_PUB_CCE =...

RSA decrypt message [closed]

c++,c,openssl,cryptography,rsa
My programs fails when I try to decrypt encrypted messages. My code: char *pri_key[] = "some key"; // ---> some key, that i've got from server RSA *rsa; BIO *keybio; keybio = BIO_new_mem_buf(pri_key, strlen(pri_key)); rsa = PEM_read_bio_RSAPrivateKey(keybio, &rsa, NULL, NULL); // Decrypt it // Encoded message is in buff char...

Digital Signature in java / android (RSA keys)

java,android,encryption,rsa,digital-signature
I would like to generate a digital signature in my java/android project with a private key(RSA) stored in DB. My 2 keys was generated with the below code (project is in production and I cannot change it): // Get keys pair (RSA) KeyPair rsaKyePair = createKeyPair(); // Get private/ public...

RSA turning string to BigInteger [closed]

java,rsa,biginteger
I am playing around with an RSA Algorithm program and trying to make it accept a string as the message instead of a number. I thought I had the conversion right but I get an error when I run, can anyone see why? import java.math.BigInteger; import java.security.SecureRandom; public class rsa...

RSA on ASCII message problems with '\0'

encryption,ascii,rsa,null-character
I want to encrypt and decrypt ASCII messages using an RSA algorithm written in assembly. I read that for security and efficiency reasons the encryption is normally not called character-wise but a number of characters is grouped and encrypted together (e.g. wikipedia says that 3 chars are grouped). Let us...

Replicating request to Chef with Python RSA

python,openssl,rsa,chef
Goal: I need a Python 3 wrapper for Chef's REST API. Because its Python-3, PyChef is out of the question. Problem: I am trying to replicate the Chef request with Python RSA. But the wrapper results in an error message: "Invalid signature for user or client 'XXX'". I approached the...

Secure link between two peers without certificates?

java,security,encryption,cryptography,rsa
I am writing software in Java that will run on Android, Windows, Linux and OSX and want the devices to all talk to each other securely. My initial thought was just to use a asymmetric algorithm (eg. RSA) and share the public keys manually. Then sessions would be encrypted just...

Import RSA key from bouncycastle sometimes throws “Bad Data”

c#,rsa,bouncycastle
Sometimes, (frequently enough to be a serious problem between .NET and bouncy castle), a key generated by bouncycastle won't import into the dotnet RSA crypto provider. It only throws "Données Incorrectes" ; no more details. ("Bad data"). I cannot debug the problem since the guilty function implementation seems to be...

RSA key generation

c,rsa,number-theory
//test whether it is prime number ot not int prime_test(long int prime_number) { long int a, p; srand((unsigned)time(NULL)); //0 and 1 not meaning for prime test. a = rand() % (prime_number - 2) + 2; printf("a -> %li\n", a); //Lehmann Algorithm, p = a^((prime_number-1)/2) mod prime_number p = (long int)pow(a,...

Translate JavaScript code of RSA encryption to Python

javascript,python,encryption,rsa
I have this JavaScript code to encrypt text using RSA, and I need one que generates the same encrypted message, but that works with Python. JavaScript code I'm using: var key = new RSAKeyPair( "2f9ac975a8a20c1b108e678904b42aa1", "", "4a5670127da1fd4e2a51685faff367f9" ); ... I'm having trouble finding an equivalent in Python because the parameter...

PyCrypto export/import of signature

python,rsa,signature,pycrypto
created a client-server application with sockets and I am trying to transfer the signature from client to server. I convert it from tuple to string and then back to tuple. But signing stops working. How to resolve this? from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA public_key_file = open('public.pem','r') public_key...

SSH Permission denied (publickey) [closed]

linux,ubuntu,ssh,debian,rsa
I'm trying to SSH into a Debian from Ubuntu. I already have a RSA key; it's the same key that I use got my Git. I copied the key from Ubuntu to Debian using: ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] Then I modified sshd_config on Debian to include the following: RSAAuthentication yes...

RSA Public Key Conversion with just Modulus

c,openssl,rsa,public-key
I received an RSA-2048 bit public key (256 bytes) as a file which contains just those 256 bytes. Which function in SSL enables me to load this key as an RSA structure so I can convert it to another format? This is in C code using openssl source. I think...

Use OpenSSL RSA key with .Net

c++,.net,openssl,rsa
I am using openssl 0.9.6g and I have created public/private keypair using RSA_generate_key(). When I save the key with PEM_write_bio_RSAPublicKey, it gives me keys like: -----BEGIN RSA PUBLIC KEY----- ... -----END RSA PUBLIC KEY----- I have another module in .NET which throws an exception when passed in this key due...

Why not work with numbers greater than 10 digits?

c,rsa,primes
Hello community I have the following problem The following code does not converge to any solution for numbers exceeding 10 digits, and do not know where the problem can be as knowing that the number is prime would be met Fermat's little theorem in one call function. #include <stdio.h> #include...