small fixes
authorVolker Birk <vb@pep-project.org>
Sun, 03 Jul 2016 08:29:56 +0200
changeset 142866e24c2b2aa
parent 141 95ae11dfbc8f
child 143 0f81d0c0f84f
small fixes
GateKeeper.cpp
     1.1 --- a/GateKeeper.cpp	Sun Jul 03 08:09:32 2016 +0200
     1.2 +++ b/GateKeeper.cpp	Sun Jul 03 08:29:56 2016 +0200
     1.3 @@ -243,15 +243,19 @@
     1.4              key.dw_key[i] = (uint32_t) dist(gen);
     1.5  
     1.6          BCRYPT_KEY_HANDLE hKey;
     1.7 +        memset(&hKey, 0, sizeof(BCRYPT_KEY_HANDLE));
     1.8 +
     1.9          NTSTATUS status = BCryptGenerateSymmetricKey(hAES, &hKey, NULL, 0, (PUCHAR) &key, (ULONG) sizeof(aeskey_t), 0);
    1.10          assert(status == 0);
    1.11          if (status)
    1.12              throw runtime_error("BCryptGenerateSymmetricKey");
    1.13  
    1.14 +#ifndef NDEBUG
    1.15          DWORD keylength = 0;
    1.16          ULONG copied = 0;
    1.17          status = BCryptGetProperty(hKey, BCRYPT_KEY_LENGTH, (PUCHAR) &keylength, sizeof(DWORD), &copied, 0);
    1.18          assert(keylength == 256);
    1.19 +#endif
    1.20  
    1.21          return hKey;
    1.22      }
    1.23 @@ -265,6 +269,7 @@
    1.24  
    1.25          PCERT_PUBLIC_KEY_INFO uk;
    1.26          DWORD uk_size;
    1.27 +
    1.28          BOOL bResult = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO,
    1.29                  (const BYTE *) _update_key.data(), _update_key.size(), CRYPT_DECODE_ALLOC_FLAG, NULL, &uk, &uk_size);
    1.30          if (!bResult)
    1.31 @@ -272,6 +277,7 @@
    1.32  
    1.33          PUBLIC_KEY_VALUES *_uk;
    1.34          DWORD _uk_size;
    1.35 +
    1.36          bResult = CryptDecodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB,
    1.37              uk->PublicKey.pbData, uk->PublicKey.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &_uk, &_uk_size);
    1.38          LocalFree(uk);