肝心のCryptoPPでDefaultEncryptorWithMACを使うときはこのマッシュ関数を使うようです
// The purpose of this function Mash() is to take an arbitrary length input
// string and *deterministicly* produce an arbitrary length output string such
// that (1) it looks random, (2) no information about the input is
// deducible from it, and (3) it contains as much entropy as it can hold, or
// the amount of entropy in the input string, whichever is smaller.
static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int iterations)
{
if (BytePrecision(outLen) > 2)
throw InvalidArgument("Mash: output legnth too large");
size_t bufSize = RoundUpToMultipleOf(outLen, (size_t)DefaultHashModule::DIGESTSIZE);
byte b[2];
SecByteBlock buf(bufSize);
SecByteBlock outBuf(bufSize);
DefaultHashModule hash;
unsigned int i;
for(i=0; i<outLen; i+=DefaultHashModule::DIGESTSIZE)
{
b[0] = (byte) (i >> 8);
b[1] = (byte) i;
hash.Update(b, 2);
hash.Update(in, inLen);
hash.Final(outBuf+i);
}
while (iterations-- > 1)
{
memcpy(buf, outBuf, bufSize);
for (i=0; i<bufSize; i+=DefaultHashModule::DIGESTSIZE)
{
b[0] = (byte) (i >> 8);
b[1] = (byte) i;
hash.Update(b, 2);
hash.Update(buf, bufSize);
hash.Final(outBuf+i);
}
}
memcpy(out, outBuf, outLen);
}
このページによるとhttp://www.cryptopp.com/wiki/DefaultEncryptorWithMAC
DefaultEncryptorWithMAC は、2 キー トリプル DES をデフォルトの暗号化として使用し、SHA1 を MAC のデフォルト ハッシュとして使用します。ブロック暗号は CBC モードで動作します。パスワードは、パスワード ベースのキー導出関数を使用して導出されるのではなく、マッシュされます。DefaultEncryptorWithMAC を実行するたびに、時刻とクロックに基づくソルトが使用されるため、異なる結果が生成されます。
この暗号化された文字列を別のライブラリで読み取ろうとしていますが、本当に苦労しています。
秘密鍵をオンラインで SHA1 暗号化した場合、上記の Mash 関数と同じ結果が得られませんか?
上記のWebページによると、標準の暗号化技術を使用していることを示唆しているようです。他の方法で結果を解読することはできませんでした
ここの誰かが、このライブラリからこれらの関数の結果を解読した経験があることを願っています
前もって感謝します