cryptography

RSA Encryption-Decryption : BadPaddingException : Data must start with zero

拥有回忆 提交于 2019-12-20 17:36:09
问题 I'm sorry to ask your skills about a question asked so many times. I have an issue about RSA crypthography. I've already checked the other topics about this issue but i didn't find any helpful answer. I hope you'll be able to help me. I want to read a file, crypt its contain and then decrypt it and put these decrypted bytes in a new file. I actually can : - get the bytes of a file - crypt it I have the exception : javax.crypto.BadPaddingException: Data must start with zero. Here is my code :

Can we have multiple public keys with a single private key for RSA?

自古美人都是妖i 提交于 2019-12-20 16:19:48
问题 Can we have multiple public keys associated with a single private key for RSA public-key encryption? 回答1: In practice and with respect to security, no, mathematically, yes. If you have a private key (N, D), there is algebraically an infinite number of solutions to the equation 1 = E*D (mod Phi(N)). However, if you make two such solutions (E, N) and (E', N) that both satisfy the equation public, you will have compromised the secrecy of the private key. However given one of the usual asymmetric

Can we have multiple public keys with a single private key for RSA?

回眸只為那壹抹淺笑 提交于 2019-12-20 16:19:15
问题 Can we have multiple public keys associated with a single private key for RSA public-key encryption? 回答1: In practice and with respect to security, no, mathematically, yes. If you have a private key (N, D), there is algebraically an infinite number of solutions to the equation 1 = E*D (mod Phi(N)). However, if you make two such solutions (E, N) and (E', N) that both satisfy the equation public, you will have compromised the secrecy of the private key. However given one of the usual asymmetric

How can I check INITIALIZE UPDATE and EXTERNAL AUTHENTICATE correctness?

微笑、不失礼 提交于 2019-12-20 15:32:11
问题 I sent 80 50 00 00 08 00 00 00 00 00 00 00 00 [ INITILIZE UPDATE Command] via opensc-tool to my java card and received 00 00 11 60 01 00 8A 79 0A F9 FF 02 00 11 79 11 36 5D 71 00 A5 A5 EC 63 BB DC 05 CC [ Init Response ] as its response from the card. As you see: In the command,I send 00 00 00 00 00 00 00 00 as Host Challenge , And in the response : 00 00 11 60 01 00 8A 79 0A F9 = Key diversification data FF 02 = Key information 00 11 79 11 36 5D 71 00 = Card challenge A5 A5 EC 63 BB DC 05 CC

AES 256 bit encryption - java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long

醉酒当歌 提交于 2019-12-20 15:32:09
问题 Below is my encryption logic. Although my IV is 16bytes long, I still get an error with invalid IV length. Would appreciate any help @Override public String encrypt(String dataToEncrypt, String IV) throws Exception{ if(encryptionKey.length() < 10){ encryptionKey = generateEncryptionKey().toString(); } System.out.println("number of IV bytes is "+IV.length()+" "+IV); Cipher cipher = Cipher.getInstance(encrpytionAlgo); SecretKey key = new SecretKeySpec(encryptionKey.getBytes(Charset.forName("UTF

Java AES cipher text size

牧云@^-^@ 提交于 2019-12-20 15:28:22
问题 I'm using a very standard way of Java AES encryption / decryption. byte[] key = hexStringToByteArray("C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF"); byte[] message = hexStringToByteArray("01A0A1A2A3A4A5A6A703020100060001"); SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); // Instantiate the cipher Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); byte[] encrypted = cipher.doFinal(message); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec); byte[]

PHP: Short id like Youtube, with salt

两盒软妹~` 提交于 2019-12-20 14:21:47
问题 I need to encode/encrypt database ids and append them to my URLs. Security is not an issue I am trying to deal with, but I am looking for something with moderate security. The main goal is to have short ids that are unique and URL-safe. The following snippet seems like it will do what I need (from http://programanddesign.com/php/base62-encode/) function encode($val, $base=62, $chars='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { // can't handle numbers larger than 2^31-1

Manual verification of XML Signature

☆樱花仙子☆ 提交于 2019-12-20 12:41:03
问题 I can successfully do manual reference validation (canonicalize every referenced element --> SHA1 --> Base64 --> check if it's the same of DigestValue content) but I fail with the verification of the SignatureValue. Here's the SignedInfo to canonicalize and hash: <ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod> <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09

Why do we need a constant time *single byte* comparison function?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 10:17:19
问题 Looking at Go standard library, there's a ConstantTimeByteEq function that looks like this: func ConstantTimeByteEq(x, y uint8) int { z := ^(x ^ y) z &= z >> 4 z &= z >> 2 z &= z >> 1 return int(z) } Now, I understand the need for constant time string (array, etc.) comparison, as a regular algorithm could short-circuit after the first unequal element. But in this case, isn't a regular comparison of two fixed-sized integers a constant time operation at the CPU level already? 回答1: Not

xcode ios HMAC SHA 256 hashing

情到浓时终转凉″ 提交于 2019-12-20 09:54:14
问题 So I'm trying to figure out how to do a hmacshad256 hash on ios as that's the hash I did for the wcf service api I made. I've been trying to look for some info about it but would usually just end up getting a SHA-256 hash. This is the only reference I have: Need to generate HMAC SHA256 hash in Objective C as in Java And I'm not sure if that's the only way to do it (importing a java hmac class) Any help is appreciated. Thanks! 回答1: NSString * parameters = @"string to hash" NSString *salt = @