aes

OpenSSL EVP API: How to decrypt the encrypted file using a symmetric key file

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi I'm working on C on Linux. I have a query related to symmetric key decryption. I have generated an symmetric key using the below command. openssl rand base64 512 > sym.key Using this key ( sym.key ) I have encrypted a file with below command. openssl enc -aes-256-cbc -in temp.txt -out temp.enc -kfile sym.key It has generated an encrypted file temp.enc . Now, I have to use the same key ( sym.key ) with EVP Decrypt API's and have to decrypt this encrypted file. Could any one suggest me a better approach for this. Here is the code unsigned

How to fix Invalid AES key length?

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on a web based text encryption and decryption project on eclipse(following Struts 2) Whenever I enter the password and the plain text I get a Invalid AES Key Length error. The Service Class(SymAES.java) package com.anoncrypt.services; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class SymAES { private static final String ALGORITHM = "AES"; private static byte[] keyValue= new byte[] { 'T', 'h', 'i', 's', 'I', 's',

AES encrypt with openssl decrypt using java

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have to encrypt an xml file using openssl command line or a C api. The output shall be Base64. A java programm will be used for decrypting. This programm is provided by the customer and cannot be changed (they are using this code for legacy applications). As you can see in the code below the customer provides a passphrase so the key will be generated using the SecretKeySpec method. Java code: // Passphrase private static final byte[] pass = new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0','1', '2', '3', '4', '5' }; public

EIdOSSLUnderlyingCryptoError and “Error connecting with SSL. error:14094410…”

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a problem with Indy components in Delphi 10.1 Berlin on OS X. I'm using TIdHTTP to connect to a webservice using HTTPS. The problem is connecting to a server from an OS X client. When running on OS X, I get this same error all the time: Project raised exception class EIdOSSLUnderlyingCryptoError with message 'Error connecting with SSL. error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure'. I set the TIdHTTP.IOHandler property to use OpenSSL: IdHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); On OS X,

InvalidCiphertext exception when decrypting ciphertext

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working in a new protocol for secure communication and I'm having problems to decrypt the ciphertext. The data packet is saved in a uint8_t* variable and encrypted. Until this part is all going well. But when I try to decrypt I got the followings problems: 1) If I send the vector and the size (it's really 20 but I just want to decrypt the last 16 bytes): CBC_Mode< AES >::Decryption decryptor; decryptor.SetKeyWithIV( key, CryptoPP::AES::DEFAULT_KEYLENGTH, iv ); CryptoPP::StringSource ss( vector+4, 16 , true, new CryptoPP:

Redshift Python encrypt/decrypt UDF Error - String contains invalid or unsupported UTF8 codepoints

匿名 (未验证) 提交于 2019-12-03 01:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to create the below encrypt and decrypt UDF's in Redshift. Library: create library pyaes language plpythonu from 's3://aws_python/library/pyaes/pyaes.zip' credentials 'aws-role' region as 'aws-region'; Encrypt: CREATE OR REPLACE FUNCTION test.aes_encrypt(input varchar(max)) RETURNS varchar(max) AS ' if input is None: return None import pyaes key = ''abcdefghijklopoo'' aes = pyaes.AESModeOfOperationCTR(key) encrypted_msg = aes.encrypt(input) return encrypted_msg ' LANGUAGE plpythonu STABLE; Tried with below options as well: encrypted

AES Encryption- large files

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am doing AES encryption using EVP interface of OpenSSL in C language in the 128/192/256 cbc modes. I found a nice example in stackoverflow with which I have started programming. What I would like to know is: What is the default padding used while encryption? What happens if I have large data. Do I have to code to divide it into data blocks of 128 bits? or does EVP interface takes care of it? What should be the size of the IV for 128bit, 192bit and 256bit cbc modes(where only the key lengths are 128, 192, 256 respectively and the block size

PHP Java AES CBC Encryption Different Results

China☆狼群 提交于 2019-12-03 00:51:51
PHP Function: $privateKey = "1234567812345678"; $iv = "1234567812345678"; $data = "Test string"; $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $privateKey, $data, MCRYPT_MODE_CBC, $iv); echo(base64_encode($encrypted)); Result: iz1qFlQJfs6Ycp+gcc2z4w== Java Function public static String encrypt() throws Exception{ try{ String data = "Test string"; String key = "1234567812345678"; String iv = "1234567812345678"; javax.crypto.spec.SecretKeySpec keyspec = new javax.crypto.spec.SecretKeySpec(key.getBytes(), "AES"); javax.crypto.spec.IvParameterSpec ivspec = new javax.crypto.spec.IvParameterSpec

Encryption using AES-128 in Java

十年热恋 提交于 2019-12-03 00:51:21
I have a problem with ecrypting data using AES-128/ecb/PKCS5Padding+base64. I am using the following code to encrypt my data: String input = "{\"action\":\"getQuestion\"}"; String key = "4288f0b8060ca1b682bf795f2617cfdc"; byte[] data = input.getBytes(); byte[] encrypted = null; byte[] keyBytes = new BigInteger(key, 16).toByteArray(); SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); encrypted = cipher.doFinal(data); System.out.println(Base64.encodeBytes(encrypted)); I receive

How to decrypt AES encrypted file with '-nosalt' param

大城市里の小女人 提交于 2019-12-03 00:50:45
I'm new to encryption. This question is subquestion of my previous one. I have a file encrypted with OpenSSL util: openssl aes-256-cbc -in fileIn -out fileOUT -p -k KEY I'm using this code to decrypt it: byte[] encrypted = IOUtils.toByteArray(inputStream); Security.addProvider(new BouncyCastleProvider()); String password = "abc"; Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC"); // Openssl puts SALTED__ then the 8 byte salt at the start of the // file. We simply copy it out. byte[] salt = new byte[8]; System.arraycopy(encrypted, 8, salt, 0, 8); SecretKeyFactory fact =