GateKeeper.cpp
changeset 118 397dc2da7805
parent 117 a0bb0649aae8
child 119 7b1eac29288f
     1.1 --- a/GateKeeper.cpp	Wed Jun 22 12:07:46 2016 +0200
     1.2 +++ b/GateKeeper.cpp	Wed Jun 22 12:47:18 2016 +0200
     1.3 @@ -165,7 +165,7 @@
     1.4          pi.cbLabel = sizeof(r);
     1.5  
     1.6          ULONG result_size;
     1.7 -        PUCHAR _result;
     1.8 +        PUCHAR _result = NULL;
     1.9          status = BCryptEncrypt(hUpdateKey, (PUCHAR) _update_key.data(), _update_key.size(), &pi, NULL, 0, NULL, 0, &result_size, BCRYPT_PAD_OAEP);
    1.10          if (status)
    1.11              throw runtime_error("BCryptEncrypt: calculating result size");
    1.12 @@ -174,10 +174,12 @@
    1.13          ULONG copied;
    1.14          status = BCryptEncrypt(hUpdateKey, (PUCHAR) _update_key.data(), _update_key.size(), &pi, NULL, 0, _result, result_size, &copied, BCRYPT_PAD_OAEP);
    1.15          if (status)
    1.16 -            throw runtime_error("BCryptEncrypt: calculating result size");
    1.17 +            throw runtime_error("BCryptEncrypt: encrypting using update_key");
    1.18  
    1.19          stringstream s;
    1.20 -        s << hex << _result;
    1.21 +        s << hex << setw(2) << setfill('0');
    1.22 +        for (ULONG i = 0; i < copied; i++)
    1.23 +            s << (int) _result[i];
    1.24          delete[] _result;
    1.25          s >> result;
    1.26