public-key-encryption

RSA 2048 Encryption Decryption - Exception

给你一囗甜甜゛ 提交于 2019-12-03 08:57:07
I am trying to encrypt and decrypt the data with RSA 2048. We have one public key and private key and will be using same throughout. but the problem is, when I decrypt, I am getting javax.crypto.BadPaddingException: Data must start with zero File file = new File("C:\\temp-ldi\\pubkey.txt"); FileWriter writer = new FileWriter(file); file.createNewFile(); encryptedText = RSACrypto.encrypt("PLAIN TEXT"); //no argument of pub-key, generate key pair writer.write(new BASE64Encoder().encode(RSACrypto.pubKeyToBytes(RSACrypto.publicKey))); writer.close(); file = new File("C:\\temp-ldi\\privkey.txt");

Can a public key have a different length (encryption) than the private key?

我与影子孤独终老i 提交于 2019-12-03 08:04:16
I have a 1024 bits private key, and use it to generate a public key. Does that automatically mean that my public key also has 1024 encryption? Or can it be of a lesser encryption size? (512, 256...) PS: What i'm mostly interested in, and talking about, is the size of the modulus ("n") in RSA keys. The size is typically 1024 or 2048 bits. But I'm glad to see that this sparked a discussion, and all this is feeding my interest in cryptography. No. The public key in a key pair always matches the private key size, in fact it is derived from the private key. However, with some public key

RSA Encryption in Java: Cross Platform Issues?

核能气质少年 提交于 2019-12-03 06:14:00
问题 The Situation I'm working with RSA encryption in Java. I'm trying to encrypt data on an HTC Saphire (32B) developer phone equipped with Cyanogenmod's Android 2.2 and then decrypt said data on a 64 bit server running Mandriva Linux 2010. I am using the same public key, private key pair on both machines, can correctly encrypt/decrypt data on the Android phone, can correctly encrypt/decrypt data on the Linux server, but I am unable to encrypt data on the phone and then decrypt it on the server.

.NET implementation (libraries) of elliptic curve cryptography

徘徊边缘 提交于 2019-12-03 06:07:51
Please can you suggest any implementation of elliptical curve cryptography to be used on .NET platform? Also if you have used them, can you tell me the recommended curves that should be used? [EDIT] As @FatCat mentioned, its implementation is available in .NET framework 3.5 but that is only available on windows vista. Can you please suggest another way/library to use it? Check out the Bouncy Castle library for C#, it has ECDH and ECDSA. The .NET Framework already includes Diffie-Hellman, which is an elliptic curve crypto algorithm. Look under System.Security.Cryptography.ECDiffieHellmanCng .

How do I export a public key <SecKey> that was generated using SecKeyGeneratePair to be used on a server?

坚强是说给别人听的谎言 提交于 2019-12-03 05:06:50
I generated a keeper using SecKeyGeneratePair. var publicKeyPtr, privateKeyPtr: Unmanaged<SecKey>? let publicKeyParameters: [String: AnyObject] = [ kSecAttrIsPermanent: true, kSecAttrApplicationTag: "com.example.site.public" ] let privateKeyParameters: [String: AnyObject] = [ kSecAttrIsPermanent: true, kSecAttrApplicationTag: "com.example.site.private" ] let parameters: [String: AnyObject] = [ kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeySizeInBits: 2048, kSecPublicKeyAttrs.takeUnretainedValue() as String: publicKeyParameters, kSecPrivateKeyAttrs.takeUnretainedValue() as String:

Rainbow tables as a solution to large prime factoring

蹲街弑〆低调 提交于 2019-12-03 04:44:15
问题 In explanations I've read about public key cryptography, it is said that some large number is come up with by multiplying together 2 extremely large primes. Since factoring the product of large primes is almost impossibly time-consuming, you have security. This seems like a problem that could be trivially solved with rainbow tables. If you know the approximate size of primes used and know there are 2 of them, you could quickly construct a rainbow table. It'd be a mighty large table, but it

Cube root modulo P — how do I do this?

坚强是说给别人听的谎言 提交于 2019-12-03 04:34:30
问题 I am trying to calculate the cube root of a many-hundred digit number modulo P in Python, and failing miserably. I found code for the Tonelli-Shanks algorithm which supposedly is simple to modify from square roots to cube roots, but this eludes me. I've scoured the web and math libraries and a few books to no avail. Code would be wonderful, so would an algorithm explained in plain English. Here is the Python (2.6?) code for finding square roots: def modular_sqrt(a, p): """ Find a quadratic

ECC algorithm key mismatch

橙三吉。 提交于 2019-12-03 04:07:30
I am trying to implement ECC algorithm on Android. I am currently using spongy castle to implement it. The key generation cone snippet is as follows : KeyPairGenerator kpg = null; try { kpg = KeyPairGenerator.getInstance("ECIES");// Do i have to do any changes here? } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } ECGenParameterSpec brainpoolP160R1 = new ECGenParameterSpec("brainpoolP160R1"); try { kpg.initialize(brainpoolP160R1); } catch (InvalidAlgorithmParameterException) { } KeyPair kp = kpg.generateKeyPair(); PublicKey publicKey = kp.getPublic(); PrivateKey privateKey = kp

PKCS#7 Signin and verify sign

孤街浪徒 提交于 2019-12-03 04:06:36
I am trying to sign and verify sign using PKCS#7. I am following book beginning cryptography with java . I have written sample code to sign and verify. When i am trying to attach a signature and write it to a file and then trying to verify i am getting exception (Exception is given below ) I want to know how do we write this signed data to a file ? Do i need to share keystore also to second person who will verify the sign? org.bouncycastle.cms.CMSException: message-digest attribute value does not match calculated value at org.bouncycastle.cms.SignerInformation.doVerify(Unknown Source) at org

How to use apache vfs2 for sftp with public-private-key and without password

≡放荡痞女 提交于 2019-12-03 03:44:29
Currently I am using apache vfs2 to download files from a sftp. For authentication I use user-name and password. Is there a way to use vfs2 only with public-private-keys and without a password? I think I have use this function,but how? Set it only to "yes"? SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(options, "no"); This is my current code (snippet): private boolean downloadFile(){ StandardFileSystemManager sysManager = new StandardFileSystemManager(); //download der Datei try { sysManager.init(); FileObject localFile = sysManager.resolveFile(localFilePath); FileObject