Description
mdAES.bas is a pure VB6 implementation of AES block cipher incl. AES in CBC mode (w/ PKCS#5 padding) and in Counter mode.
Usage
First you have to initialize AES context with CryptoAesInit (incl. initial Nonce for CBC), then to encrypt a byte-array in-place call CryptoAesCbcEncrypt with parameter Finalize:=False as a streaming API until the final chunk.
Keep in mind that in CBC mode all chunks except the final one must be multiple of AES block size (16 bytes) and the final one is padded to AES block size (16 bytes) so output ciphertext size might be bigger than input plaintext which is normal.
As a consequence of appended padding the CryptoAesCbcDecrypt function accepts encrypted ciphertext chunks only sized to multiple of block size (16 bytes) and decrypts these in-place until final chunk which gets resized to actual plaintext size as it were before padding.
Compiled VB6 code w/ all optimizatins is quite performant and you can expect rates of ~280MB/s for AES-128 and ~215MB/s for AES-256 and additionally calculating MAC will obvisouly make some dent on these rates.
For Counter mode you can use CryptoAesInit and CryptoAesCtrCrypt the same for both encryption and decryption which can be used as a streaming API only with chunk sizes of multiple of block size (16 bytes) besides the final one.
cheers,
</wqw>
mdAES.bas is a pure VB6 implementation of AES block cipher incl. AES in CBC mode (w/ PKCS#5 padding) and in Counter mode.
Usage
First you have to initialize AES context with CryptoAesInit (incl. initial Nonce for CBC), then to encrypt a byte-array in-place call CryptoAesCbcEncrypt with parameter Finalize:=False as a streaming API until the final chunk.
Keep in mind that in CBC mode all chunks except the final one must be multiple of AES block size (16 bytes) and the final one is padded to AES block size (16 bytes) so output ciphertext size might be bigger than input plaintext which is normal.
As a consequence of appended padding the CryptoAesCbcDecrypt function accepts encrypted ciphertext chunks only sized to multiple of block size (16 bytes) and decrypts these in-place until final chunk which gets resized to actual plaintext size as it were before padding.
Compiled VB6 code w/ all optimizatins is quite performant and you can expect rates of ~280MB/s for AES-128 and ~215MB/s for AES-256 and additionally calculating MAC will obvisouly make some dent on these rates.
For Counter mode you can use CryptoAesInit and CryptoAesCtrCrypt the same for both encryption and decryption which can be used as a streaming API only with chunk sizes of multiple of block size (16 bytes) besides the final one.
Code:
'--- mdAES.bas
Code is in next post
</wqw>