summaryrefslogtreecommitdiff
path: root/test.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-07-18 04:35:30 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-07-18 04:35:30 +0000
commita89df27c0f7ded0a673dc84ce0b0e24c6d05e0d0 (patch)
treea25c153b42dc3f510a7981a031bd04dfa0a7a712 /test.cpp
parent656db5504c8c656d3981fed232da44b2f28b1feb (diff)
downloadcryptopp-a89df27c0f7ded0a673dc84ce0b0e24c6d05e0d0.tar.gz
misc changes
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@103 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'test.cpp')
-rw-r--r--test.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/test.cpp b/test.cpp
index 063e6dd..e371652 100644
--- a/test.cpp
+++ b/test.cpp
@@ -51,6 +51,8 @@ bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const c
void DigestFile(const char *file);
void HmacFile(const char *hexKey, const char *file);
+void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile);
+
string EncryptString(const char *plaintext, const char *passPhrase);
string DecryptString(const char *ciphertext, const char *passPhrase);
@@ -66,10 +68,10 @@ void InformationRecoverFile(int threshold, const char *outFilename, char *const
void GzipFile(const char *in, const char *out, int deflate_level);
void GunzipFile(const char *in, const char *out);
-void Base64Encode(const char *in, const char *out);
-void Base64Decode(const char *in, const char *out);
-void HexEncode(const char *in, const char *out);
-void HexDecode(const char *in, const char *out);
+void Base64Encode(const char *infile, const char *outfile);
+void Base64Decode(const char *infile, const char *outfile);
+void HexEncode(const char *infile, const char *outfile);
+void HexDecode(const char *infile, const char *outfile);
void ForwardTcpPort(const char *sourcePort, const char *destinationHost, const char *destinationPort);
@@ -291,6 +293,8 @@ int CRYPTOPP_CDECL main(int argc, char *argv[])
}
else if (command == "hmac")
HmacFile(argv[2], argv[3]);
+ else if (command == "ae")
+ AES_CTR_Encrypt(argv[2], argv[3], argv[4], argv[5]);
else if (command == "h")
{
FileSource usage("usage.dat", true, new FileSink(cout));
@@ -298,7 +302,7 @@ int CRYPTOPP_CDECL main(int argc, char *argv[])
}
else
{
- cerr << "Unrecognized command.\n";
+ cerr << "Unrecognized command. Run \"cryptest h\" to obtain usage information.\n";
return 1;
}
return 0;
@@ -329,6 +333,14 @@ void FIPS140_GenerateRandomFiles()
#endif
}
+SecByteBlock HexDecodeString(const char *hex)
+{
+ StringSource ss(hex, true, new HexDecoder);
+ SecByteBlock result(ss.MaxRetrievable());
+ ss.Get(result, result.size());
+ return result;
+}
+
RandomPool & GlobalRNG()
{
static RandomPool randomPool;
@@ -442,6 +454,14 @@ void HmacFile(const char *hexKey, const char *file)
FileSource(file, true, new HashFilter(*mac, new HexEncoder(new FileSink(cout))));
}
+void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile)
+{
+ SecByteBlock key = HexDecodeString(hexKey);
+ SecByteBlock iv = HexDecodeString(hexIV);
+ CTR_Mode<AES>::Encryption aes(key, key.size(), iv);
+ FileSource(infile, true, new StreamTransformationFilter(aes, new FileSink(outfile)));
+}
+
string EncryptString(const char *instr, const char *passPhrase)
{
string outstr;