aes

AES Decryption has different behavior in iOS 7 than iOS 8/9

自作多情 提交于 2019-12-05 02:47:14
问题 The following method returns different results when run on iOS 7 than it does on iOS 8/9. + (NSData *)decryptData:(NSData *)data key:(NSData *)key iv:(NSData *)iv; { NSData *result = nil; // setup key unsigned char cKey[FBENCRYPT_KEY_SIZE]; bzero(cKey, sizeof(cKey)); [key getBytes:cKey length:FBENCRYPT_KEY_SIZE]; // setup iv char cIv[FBENCRYPT_BLOCK_SIZE]; bzero(cIv, FBENCRYPT_BLOCK_SIZE); if (iv) { [iv getBytes:cIv length:FBENCRYPT_BLOCK_SIZE]; } // setup output buffer size_t bufferSize =

AES加解密异常java.security.InvalidKeyException: Illegal key size

天涯浪子 提交于 2019-12-05 02:43:47
AES加解密异常 Java后台AES解密,抛出异常如下: java.security.InvalidKeyException: Illegal key size Illegal key size or default parameters 是指密钥长度受限制,java运行时环境读到的是受限的policy文件。 policy文件位于${java_home}/jre/lib/security 目录下。 这种限制是因为美国对软件出口的控制。 解决办法: 去除该限制需下载 Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files, 覆盖上述目录下的对应jar文件(local_policy.jar, US_export_policy.jar)即可。 下载地址: JDK6 http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html JDK7 http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html JDK8 http://www.oracle.com/technetwork/java

Which encryption mode ECB, CBC, CFB

允我心安 提交于 2019-12-05 02:22:32
问题 My php script and my c# application will pass a hash string to each other that is 32 chars long, what is the best mode for this? I thought ECB but am unsure as it says if using more then 1 block dont use. How do I know how big the block is? They will occasionally pass a large text file, which would be the best mode for encrypting this...CBC? Any good useful reads welcome... Thanks 回答1: ECB is the simplest mode and really not recommended (it's not quite as secure as other modes). Personally I

AES 256 decryption - Is IV safe to share?

删除回忆录丶 提交于 2019-12-05 01:48:10
问题 Following on this question and its answer, I am creating an application that given a password string, will convert a plaintext and store its ciphertext, the salt generated and the initialization vector in a text file. In the following code : public String decrypt(CryptGroup cp) throws Exception { String plaintext = null; SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); KeySpec spec = new PBEKeySpec(password, cp.getSalt(), ITERATIONS, KEY_SIZE); SecretKey

Java AES with CBC using passphrase

孤街醉人 提交于 2019-12-05 01:27:57
问题 I want to implement 256 key AES with CBC encryption with Java. Recipient sent me 256 bit passphrase as a String 'absnfjtyrufjdngjvhfgksdfrtifghkv' and it perfectly works using this openssl command: echo test | openssl enc -aes-256-cbc -a -k 'absnfjtyrufjdngjvhfgksdfrtifghkv' The output in base64 format is : U2FsdGVkX1/yA4J8T+i1M3IZS+TO/V29rBJNl2P88oI= When i decript it, it returns original input string : echo U2FsdGVkX1/yA4J8T+i1M3IZS+TO/V29rBJNl2P88oI= | openssl enc -d -aes-256-cbc -a -k

PHP7.2中AES加密解密方法mcrypt_module_open()替换方案 Function mcrypt_get_block_size() is deprecated

这一生的挚爱 提交于 2019-12-05 01:02:47
直接粘代码,该类是基于微信公众号消息加密解密所提供的 PHP DEMO 改造而来,目前使用于彬彬大学APP接口token校验中。 php的mcrypt 扩展已经过时了大约10年,并且用起来很复杂。因此它被废弃并且被 OpenSSL 所取代。 从PHP 7.2起它将被从核心代码中移除并且移到PECL中。PHP手册在7.1迁移页面给出了替代方案,就是用OpenSSL取代MCrypt. class Aes { private $hex_iv = '00000000000000000000000000000000'; # converted JAVA byte code in to HEX and placed it here private $key = '397e2eb61307109f6e68006ebcb62f98'; #Same as in JAVA function __construct($key) { $this->key = $key; $this->key = hash('sha256', $this->key, true); } /* function encrypt($str) { $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); mcrypt_generic_init(

How to decrypt AES-128 encrypted m3u8 video files?

十年热恋 提交于 2019-12-05 00:35:34
问题 I trying to decrypt AES-128 encrypted m3u8 video files such as this one : the m3u8 file : #EXTM3U #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-ALLOW-CACHE:NO #EXT-X-VERSION:2 #EXT-X-FAXS-CM:MII6lAYJKoZIhvcNAQcCoII6hTCCOoECAQExCzAJBgUrDgMCGgUAM... very long key... #EXT-X-KEY:METHOD=AES-128,URI="faxs://faxs.adobe.com",IV=0X99b74007b6254e4bd1c6e03631cad15b #EXT-X-TARGETDURATION:8 #EXTINF:8, video.mp4Frag1Num0.ts #EXTINF:8, video.mp4Frag1Num1.ts ... I've tried with openssl : openssl aes-128-cbc -d -kfile key

Decryption error on Android 4.4

两盒软妹~` 提交于 2019-12-05 00:30:24
问题 I have algorithm of encryption\ decryption files: private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception { SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); byte[] encrypted = cipher.doFinal(clear); return encrypted; } private static byte[] getRawKey(byte[] seed) throws Exception { KeyGenerator kgen = KeyGenerator.getInstance("AES"); SecureRandom sr = new

Java 7 Kerberos Issue - AES128 Corrupt checksum

喜你入骨 提交于 2019-12-05 00:28:46
问题 I am migrating from Java 6 to Java 7 and am running into a problem with Kerberos authentication. It looks to me that the underlying encryption type order is switched and as a result a different encryption type is used. In this case Aes128CtsHmacSha1EType is being used for part of the transaction when Java 7 is run. ArcFourHmacEType is used when Java 6 is run and for the other part of the Java 7 run. Other details: running on Linux (Fedora 16) against a Windows Active Directory server. I know

Test for AES-NI instructions from C#

家住魔仙堡 提交于 2019-12-05 00:11:30
问题 I want to know if there is a way to test for the presence of AES-NI in the host system's CPU from C#.NET. Let me say up front that this question is not asking about how to use AES-NI from .NET. It turns out simply using AESCryptoServiceProvider will use AES-NI if it is available. This result is based on independent benchmarks I did comparing the performances of AESCryptoServiceProvider against the benchmarks provided in TrueCrypt, which does indeed support AES-NI. The results were