aes

Openssl aes.h [Linker error] undefined reference to

試著忘記壹切 提交于 2019-12-05 18:42:30
I tried to make simple test program with AES decryption using OpenSSL ibaries. The compiler/linker shows me an error. Compiler: Dev-Cpp [Linker error] undefined reference to `AES_set_decrypt_key' [Linker error] undefined reference to `AES_decrypt' code: #include <stdio.h> #include <openssl/aes.h> int main(){ AES_KEY k; unsigned char key[]="2641cf97291c6ea02b930a4e2a824990"; unsigned char in[]="adc8f4ad114433ffaf4597c9738d257c504db763c29d238aa05bd21e1107809f"; unsigned char out[150]; AES_set_decrypt_key(key, 256, &k); AES_decrypt(in, out, &k); printf("%s\n", out); } Tnx You should link against

AES Encrypting a Microsoft Access Field Via VBA

吃可爱长大的小学妹 提交于 2019-12-05 18:27:32
I need to create a Microsoft Access database, but have a need, in one of my tables, for a single field to be strongly encrypted. Since AES requires both a key and an initialization vector, I've decided to solve this problem by requiring a password to access the database (as the key), and a field in the table to hold a SHA1 hash of the plaintext of the encrypted field. Does anyone know where I can find VBA-compatible code to actually do the encryption? Some alternatives to writing it from scratch; You can do it with the native CryptoAPI (the root API is CryptAquireContext ) You can use

Extremely slow built-in AES encryption with Java

眉间皱痕 提交于 2019-12-05 18:24:13
I have a lot of very small data (19 Bytes) that need to be encrypted and sent to a remote server via tcp in encrypted format. I am using the code below to do this. package aesclient; import java.io.OutputStream; import java.net.Socket; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; public class AESClient { static byte[] plaintext = new byte[] {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53}; public static void main(String[] args) {

Late authentication in OpenSSL GCM decryption

爷,独闯天下 提交于 2019-12-05 18:14:31
I am using OpenSSL's EVP interfaces to implement AES encryption using GCM mode. Now GCM, being one of the authentication modes, provides cipher text integrity. Meaning it generates a tag (MAC - message authentication code) on the cipher text (and additional data, if provided). This tag can later be checked before decryption, to ensure that the cipher text has not been modified. I have implemented the encryption as per this blog post: http://incog-izick.blogspot.in/2011/08/using-openssl-aes-gcm.html While decrypting I am using the following API calls (in that order): // setting cipher, key and

Java实现AES加密解密

余生颓废 提交于 2019-12-05 18:10:12
之前常用两种加密算法:Base64和Md5,前者容易破解,后者不可逆。 AES采用对称加密方式,破解难度非常大,在可逆的基础上,能很好的保证数据的安全性。 这里介绍Java中实现AES加密算法的加密与解密实现: import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; import org.springframework.util.Base64Utils; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; import javax.crypto.*; import javax.crypto.spec.SecretKeySpec; import java.io.UnsupportedEncodingException; import java.security.Key; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; public class AesUtil { public static void main(String[] args) throws

Rijndael Padding Error

你离开我真会死。 提交于 2019-12-05 16:55:21
Hello I am trying to encrypt / decrypt a string via Rijaendal. I simply can't figure out why the decryption blows up. I always end up with an incorrect padding error. One thing that throws me off is the result of my encryption which I return as HEX array. It has a length of 14 bytes. In my decryption function, the same byte array ends up having 16 bytes upon conversion from HEX. Any help would be appreciated: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace rjandal { class Program { static void Main(string[] args) { string DataForEncrypting =

How many characters to create a byte array for my AES method?

倖福魔咒の 提交于 2019-12-05 16:49:44
I am using the AES methods here: http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx I want to have a string value that I will convert to byte array and pass it to the AES encrypt method. How many characters should the string be to produce the correct byte array size that the method expects? static byte[] encryptStringToBytes_AES(string plainText, byte[] Key, byte[] IV) { // Check arguments. if (plainText == null || plainText.Length <= 0) throw new ArgumentNullException("plainText"); if (Key == null || Key.Length <= 0) throw new ArgumentNullException("Key"

Using the nonce and counter correctly for AES-CTR mode

混江龙づ霸主 提交于 2019-12-05 16:42:17
I understand that in AES Counter mode I need to use a 128 bit nonce. The naïve way to do that would be to use a random 128 bit nonce, but I'm not sure the algorithm will be able to increment the counter correctly if it's passed as all random bits. I thought the correct way to do it is to use a 96 bit nonce and also a 32 bit counter starting at 0, for example: var key = CryptoJS.enc.Hex.parse('01ab23cd45ef67089a1b2c3d4e5f6a7b'); // 128 bits / 16 bytes var nonce = '2301cd4ef785690a1b2c3dab'; // 96 bits / 12 bytes var counter = '00000000'; // 32 bits / 4 bytes var nonceAndCounter = nonce +

How to use Bouncycastle's CMac

依然范特西╮ 提交于 2019-12-05 16:10:13
I'm trying to use BouncyCastle's CMac implementation but apparently I'm doing it wrong. At least the following unit test (based on RFC 5297 test vectors) fails: @Test public void testCMacOfZeros() { byte[] key = {(byte) 0xff, (byte) 0xfe, (byte) 0xfd, (byte) 0xfc, // (byte) 0xfb, (byte) 0xfa, (byte) 0xf9, (byte) 0xf8, // (byte) 0xf7, (byte) 0xf6, (byte) 0xf5, (byte) 0xf4, // (byte) 0xf3, (byte) 0xf2, (byte) 0xf1, (byte) 0xf0, // (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, // (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, // (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, //

理解AES加密解密的使用方法

北城以北 提交于 2019-12-05 16:03:51
很多人对于AES加密并不是很了解,导致互相之间进行加密解密困难。 本文用简单的方式来介绍AES在使用上需要的知识,而不涉及内部算法。最后给出例子来帮助理解AES加密解密的使用方法。 AES的麻烦 相比于其他加密,AES加密似乎模式很多,包括ECB、CBC等等等等,每个模式又包括IV参数和Padding参数,并且,不同语言对AES加密的库设计有区别。这些导致AES加密在不同人之间联调会很麻烦。 AES属于块加密 不难理解,对越长的字符串进行加密,代价越大,所以通常对明文进行分段,然后对每段明文进行加密,最后再拼成一个字符串。块加密的一个要面临的问题就是如何填满最后一块?所以这就是PADDING的作用,使用各种方式填满最后一块字符串,所以对于解密端,也需要用同样的PADDING来找到最后一块中的真实数据的长度。 加密模式 AES分为几种模式,比如ECB,CBC,CFB等等,这些模式除了ECB由于没有使用IV而不太安全,其他模式差别并没有太明显,大部分的区别在IV和KEY来计算密文的方法略有区别。具体可参考 WIKI的说明 。 另外,AES分为AES128,AES256等,表示期待秘钥的长度,比如AES256秘钥的长度应该是256/8的32字节,一些语言的库会进行自动截取,让人以为任何长度的秘钥都可以。而这其实是有区别的。 IV的作用 IV称为初始向量,不同的IV加密后的字符串是不同的