--2.C++--------------------------------------
int keyLength = AES::DEFAULT_KEYLENGTH; // 16 bytes = 128 bit key
int defBlockSize = AES::BLOCKSIZE;
// Generate a random key longnTemp=AES::DEFAULT_KEYLENGTH;bytekey[AES::DEFAULT_KEYLENGTH+2];memcpy(key,"1234567890123456",16);strcpy((char*)key,"1234567890123456");// Generate a random IV byteiv[AES::BLOCKSIZE+2];strcpy((char*)iv,"1234567890123456");charplainText[1024]="Hello!";byteciphertext[1024];intmessageLen=(int)strlen(plainText);////////////////////////////////////////////////////////////////////////// // EncryptCFB_Mode<AES>::EncryptioncfbEncryption(key,AES::DEFAULT_KEYLENGTH,
(This articel has been cross-posted to 'Crypto++ mailing' and 'mcrypt forum')
Hello.
PHP-mcrypt on Centos 5.1 based and crypto++ library make little
different output like this.
Is it not a bug or not?
PHP : :0x3D(61).0x15(21).0x69(105).0xCD(205).0x57(87).0xD5(213).
0x00(0).0x00(0).0x00(0).
Crypto 5.5.2: 3d 19 a1 60 b3 7d 00 00 00 00 00 00 0
Which side was wrong? Who can handle this?
Here are two sources.
--1.php source--------------------------------------
<?php
$userkey2 = "1234567890123456"; //AES 용 16
$input = "Hello!";
MCRYPT_RAND);
echo "[";
echo mcrypt_enc_get_iv_size($td);
echo "]<br>AES:CFB:";
$blockkey_iv2 = "1234567890123456";
echo "[";
echo $blockkey_iv2;
echo "<br>";
$s = mcrypt_generic_init($td, $userkey2, $blockkey_iv2);
if( ($s < 0) || ($s === false))
die( "Really an error" );
$encrypted_data = mcrypt_generic($td, $input);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
echo "[";
echo $encrypted_data;
echo "<br>";
echo "-".strlen($encrypted_data).":";
ord(substr($encrypted_data, 0, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 1, 1)),
ord(substr($encrypted_data, 1, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 2, 1)),
ord(substr($encrypted_data, 2, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 3, 1)),
ord(substr($encrypted_data, 3, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 4, 1)),
ord(substr($encrypted_data, 4, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 5, 1)),
ord(substr($encrypted_data, 5, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 6, 1)),
ord(substr($encrypted_data, 6, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 7, 1)),
ord(substr($encrypted_data, 7, 1)));
printf("0x%02X(%d).", ord(substr($encrypted_data, 8, 1)),
ord(substr($encrypted_data, 8, 1)));
?>
--2.C++--------------------------------------
int keyLength = AES::DEFAULT_KEYLENGTH; // 16 bytes = 128 bit key
int defBlockSize = AES::BLOCKSIZE;
iv);
memset(ciphertext, 0x00, sizeof(ciphertext));
cfbEncryption.ProcessData((byte)ciphertext, (byte)plainText,
messageLen);
iv);
cfbDecryption.ProcessData((byte)plainText, (byte)ciphertext,
messageLen);