具体的には、リモートアシスタンスチケットのPassStubフィールドを生成しようとしています。問題は、私の結果がバイナリデータのように見えるのに、どういうわけかMicrosoftが印刷可能な文字を生成することです。
[MS-RAI]:リモートアシスタンス開始プロトコル仕様<16>セクション6:Microsoftは、「PassStub」フィールドは「MD5ハッシュとCALG_RC4、RC4ストリーム暗号化アルゴリズムを備えたPROV_RSA_FULL事前定義暗号化プロバイダーを使用して暗号化される」と述べています。
ここにデータフロー図があります:http: //msdn.microsoft.com/en-us/library/cc240189(PROT.10) .aspx#id16
この図は、ハッシュ化されたパスワードが次のような「RASessionID」で暗号化されていることを示しています。u0RIQibSMntm0wAHQZ2mhatI63sjMjX15kh/ vnciytOix8z6w + 36B01OiJoB5uYe
CryptEncryptを呼び出すと、SessionIDの長さに関するバイナリデータが生成されます。Microsoftはどういうわけか次のようなものを取得します: "Po ^ 1BiNrHBvHGP"
これを行うために私が使用しようとしているコードは次のとおりです。
HCRYPTPROV hCryptProv;
HCRYPTKEY hKey;
HCRYPTHASH hHash;
BOOL bret=0;
passwordlen = SysStringByteLen(L"password");
char RASessionID[] = "u0RIQibSMntm0wAHQZ2mhatI63sjMjX15kh/vnciytOix8z6w+36B01OiJoB5uYe";
//----------------------------------------------------------------
// Acquire a cryptographic provider context handle.
if(!CryptAcquireContext(&hCryptProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, 0))
{
return FALSE;
}
//----------------------------------------------------------------
// Create an empty hash object.
if(!CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))
{
return FALSE;
}
if(!CryptHashData(hHash, (BYTE *)bpassword, passwordlen, 0))
{
return FALSE;
}
//----------------------------------------------------------------
// Create a session key based on the hash of the password.
if(!CryptDeriveKey(hCryptProv, CALG_RC4, hHash, CRYPT_EXPORTABLE, &hKey))
{
return FALSE;
}
DWORD rasessionidlen = strlen(rasessionid);
char* proxystub = (char*)malloc(rasessionidlen*2);
strcpy(proxystub, rasessionid);
bret = CryptEncrypt(hKey, NULL, TRUE, 0, (BYTE*)proxystub, &rasessionidlen, rasessionidlen*2);
return bret;