aes

AES128 truncated decrypted text on iOS 7, no problems on iOS 8

孤街醉人 提交于 2019-12-07 23:15:49
问题 Using ciphertext encrypted with AES128 using ECB mode (this is toy encryption) and PKCS7 padding, the following code block results in the complete plaintext being recovered under iOS 8. Running the same code block under iOS 7 results in the correct plaintext, but truncated. Why is this? #import "NSData+AESCrypt.h" // <-- a category with the below function #import <CommonCrypto/CommonCryptor.h> - (NSData *)AES128Operation:(CCOperation)operation key:(NSString *)key iv:(NSString *)iv { char

How to encrypt in Python and decrypt in a C#?

不打扰是莪最后的温柔 提交于 2019-12-07 18:48:38
问题 I am new-ish to encryption, and have seen many different libraries, however many of them were created many years ago, I am just wondering what people use today to encrypt in python and something that will work with it for decrypting in C# .net I have looked into pycrypto, but from all the posts I have read, it seems like it hasn't been updated in a while (though it does seem very popular), and people have had a real struggle at getting it working with .net, Any good suggestions? I don't

Go AES CFB compatibility

帅比萌擦擦* 提交于 2019-12-07 11:23:56
问题 I am developing a client-side app in Go that relies on AES CFB. The server-side is written in C. My problem is that Go's AES CFB implementation appears to differ from many others (including OpenSSL). I wrote this to test my theory:- package main import ( "fmt" "encoding/hex" "crypto/cipher" "crypto/aes" ) func encrypt_aes_cfb(plain, key, iv []byte) (encrypted []byte) { block, err := aes.NewCipher(key) if err != nil { panic(err) } encrypted = make([]byte, len(plain)) stream := cipher

CF8 and AES decrypting MySQL AES: encodings are not same

本秂侑毒 提交于 2019-12-07 11:05:22
问题 This has become more of an exercise in what am I doing wrong than mission critical, but I'd still like to see what (simple probably) mistake I'm making. I'm using mysql (5.1.x) AES_ENCRYPT to encrypt a string. I'm using CF's generateSecretKey('AES') to make a key (I've tried it at defaul and 128 and 256 bit lengths). So let's say my code looks like this: <cfset key = 'qLHVTZL9zF81kiTnNnK0Vg=='/> <cfset strToEncrypt = '4111111111111111'/> <cfquery name="i" datasource="#dsn#"> INSERT INTO table

How to export AES key derived using CryptoAPI

对着背影说爱祢 提交于 2019-12-07 10:26:11
问题 I want to use the Windows CryptoAPI functions for AES encryption. As you know, the API has a lot of functions to create, hash and change the entered key; it derives the key and you get a handle to it. My problem is that I want to know what the derived key is? #include <Windows.h> #include <stdio.h> int main() { HCRYPTPROV hProv = 0; HCRYPTKEY hKey = 0; HCRYPTHASH hHash = 0; DWORD dwCount = 5; BYTE rgData[512] = {0x01, 0x02, 0x03, 0x04, 0x05}; LPWSTR wszPassword = L"pass"; DWORD cbPassword =

Interoperability of AES CTR mode?

自作多情 提交于 2019-12-07 09:50:22
问题 I use AES128 crypto in CTR mode for encryption, implemented for different clients (Android/Java and iOS/ObjC). The 16 byte IV used when encrypting a packet is formated like this: <11 byte nonce> | <4 byte packet counter> | 0 The packet counter (included in a sent packet) is increased by one for every packet sent. The last byte is used as block counter, so that packets with fewer than 256 blocks always get a unique counter value. I was under the assumption that the CTR mode specified that the

AES_128_CTR encryption by openssl and PyCrypto

你。 提交于 2019-12-07 08:20:30
问题 Wondering the right way to convert a AES_128_CTR encryption by openssl to PyCrypto. First, I did an encryption by openssl as following: openssl enc -aes-128-ctr -in input.mp4 -out output.openssl.mp4 -K 7842f0a1ebc38f44e3e0c81943f68582 -iv d01f40dfc8ec8cd9 And then, I tried to do the same thing through PyCrypto: from Crypto.Cipher import AES from Crypto.Util import Counter key = '7842f0a1ebc38f44e3e0c81943f68582' iv = 'd01f40dfc8ec8cd9' ctr_e = Counter.new(128, initial_value=int(iv, 16))

openssl- decrypting a base64 string with a key and IV

笑着哭i 提交于 2019-12-07 08:10:31
I'm trying to decrypt a base64 string which has been encrypted with aes256 in openssl. I was given the session key and IV, which were encrypted with my key. I converted them to hexadecimal so that I can use the following openssl command: openssl enc -d -aes256 -iv iv.hex -K sessionkey.hex -in message.b64 -out message.txt I get the error saying the IV is a non-hex value. I started out with IV and session key in base64, which was encrypted with my key. So I did the following: //convert base64 to binary openssl base64 -d -in iv.b64 -out iv.bin openssl base64 -d -in sessionkey.b64 -out sessionkey

Perl & Ruby exchange AES encrypted information

耗尽温柔 提交于 2019-12-07 07:57:26
问题 What is the equivalent to Crypt::CBC in Perl for Ruby? Note: This problem similar to PHP/Perl at stackoverflow:655691. Perl Version use Crypt::CBC; use MIME::Base64::Perl; my $cipher = Crypt::CBC->new( -key => "95A8EE8E89979B9EFDCBC6EB9797528D", -keysize => 32, -cipher => "Crypt::OpenSSL::AES" ); $encypted = $cipher->encrypt("ABCDEFGH12345678"); $base64 = encode_base64($encypted); print("$base64"); # output -> U2FsdGVkX18m1jVqRTxANhcEj6aADeOn+2cccDft2eYAMfOkYCvAAkTIOv01VHc/ $de_base64 =

How to generate a symmetric key with Bouncy Castle?

最后都变了- 提交于 2019-12-07 07:41:23
问题 How can I generate a symmetric key with Bouncy Castle? Both PrivateKeyFactory and PublicKeyFactory seem related to AsymmetricKeyParameter. I don't want to know any JCA/JCE API - instead I'm only interested in Bouncy Castle specific API. Can (should) I just generate a random bytes? 回答1: AES does not have any weak keys, so a straightforward random generation should be fine. // SecureRandom is expensive to initialize (takes several milliseconds) – // consider keeping the instance around if you