Condividi tramite


Elenchi di revoche dei certificati

[La funzionalità associata a questa pagina, DirectShow, è una funzionalità legacy. È stata sostituita da MediaPlayer, FMMediaEngine e Audio/Video Capture in Media Foundation. Queste funzionalità sono state ottimizzate per Windows 10 e Windows 11. Microsoft consiglia vivamente che il nuovo codice usi MediaPlayer, FMMediaEngine e Audio/Video Capture in Media Foundation anziché DirectShow, quando possibile. Microsoft suggerisce che il codice esistente che usa le API legacy venga riscritto per usare le nuove API, se possibile.

Questo argomento descrive come esaminare l'elenco di revoche di certificati (CRL) per i driver revocati quando si usa il protocollo COPP (Certified Output Protection Protocol).

La CRL contiene i digest dei certificati revocati e può essere fornita e firmata solo da Microsoft. La CRL viene distribuita tramite licenze DRM (Digital Rights Management). La CRL può revocare qualsiasi certificato nella catena di certificati del driver. Se un certificato nella catena viene revocato, tale certificato e tutti i certificati seguenti nella catena vengono revocati anche.

Per ottenere la CRL, l'applicazione deve usare Windows Media Format SDK, versione 9 o successiva e seguire questa procedura:

  1. Chiamare WMCreateReader per creare l'oggetto lettore di Windows Media Format SDK.
  2. Eseguire una query sull'oggetto reader per l'interfaccia IWMDRMReader .
  3. Chiamare IWMDRMReader::GetDRMProperty con un valore di g_wszWMDRMNet_Revocation per ottenere la CRL. È necessario chiamare questo metodo due volte: una volta per ottenere le dimensioni del buffer da allocare e una volta per riempire il buffer. La seconda chiamata restituisce una stringa contenente la classe CRL. L'intera stringa è codificata in base 64.
  4. Decodificare la stringa codificata base-64. È possibile usare la funzione CryptStringToBinary per eseguire questa operazione. Questa funzione fa parte di CryptoAPI.

Nota

Per usare l'interfaccia IWMDRMReader , è necessario ottenere una libreria DRM statica da Microsoft e collegare l'applicazione a questo file di libreria. Per altre informazioni, vedere l'argomento "Recupero della libreria DRM necessaria" nella documentazione di Windows Media Format SDK.

 

Se la CRL non è presente nel computer dell'utente, il metodo GetDRMProperty restituisce NS_E_DRM_UNSUPPORTED_PROPERTY. Attualmente, l'unico modo per ottenere la CRL consiste nell'acquisire una licenza DRM.

Il codice seguente mostra una funzione che restituisce la CRL:

////////////////////////////////////////////////////////////////////////
//  Name: GetCRL
//  Description: Gets the certificate revocation list (CRL).
//
//  ppBuffer: Receives a pointer to the buffer that contains the CRL.
//  pcbBuffer: Receives the size of the buffer returned in ppBuffer.
//
//  The caller must free the returned buffer by calling CoTaskMemFree.
////////////////////////////////////////////////////////////////////////
HRESULT GetCRL(BYTE **ppBuffer, DWORD *pcbBuffer)
{
    IWMReader *pReader = NULL;
    IWMDRMReader *pDrmReader = NULL;
    HRESULT hr = S_OK;

    // DRM attribute data.
    WORD cbAttributeLength = 0;
    BYTE *pDataBase64 = NULL;
    WMT_ATTR_DATATYPE type;

    // Buffer for base-64 decoded CRL.
    BYTE *pCRL = NULL;
    DWORD cbCRL = 0;

    // Create the WMReader object.
    hr = WMCreateReader(NULL, 0, &pReader);

    // Query for the IWMDRMReader interface.
    if (SUCCEEDED(hr))
    {
        hr = pReader->QueryInterface(
            IID_IWMDRMReader, (void**)&pDrmReader);
    }

    // Call GetDRMProperty once to find the size of the buffer.
    if (SUCCEEDED(hr))
    {
        hr = pDrmReader->GetDRMProperty(
            g_wszWMDRMNET_Revocation,
            &type,
            NULL,
            &cbAttributeLength
            );
    }

    // Allocate a buffer.
    if (SUCCEEDED(hr))
    {
        pDataBase64 = (BYTE*)CoTaskMemAlloc(cbAttributeLength);
        if (pDataBase64 == NULL)
        {
            hr = E_OUTOFMEMORY;
        }
    }

    // Call GetDRMProperty again to get the property.
    if (SUCCEEDED(hr))
    {
        hr = pDrmReader->GetDRMProperty(
            g_wszWMDRMNET_Revocation,
            &type,
            pDataBase64,
            &cbAttributeLength
            );
    }

    // Find the size of the buffer for the base-64 decoding.
    if (SUCCEEDED(hr))
    {
        BOOL bResult = CryptStringToBinary(
            (WCHAR*)pDataBase64,    // Base-64 encoded string.
            0,                      // Null-terminated.
            CRYPT_STRING_BASE64,    
            NULL,                   // Buffer (NULL).
            &cbCRL,                 // Receives the size of the buffer. 
            NULL, NULL              // Optional.
            );
        if (!bResult)
        {
            hr = __HRESULT_FROM_WIN32(GetLastError());
        }
    }

    // Allocate a buffer for the CRL.
    if (SUCCEEDED(hr))
    {
        pCRL = (BYTE*)CoTaskMemAlloc(cbCRL);
        if (pCRL == NULL)
        {
            hr = E_OUTOFMEMORY;
        }
    }

    // Base-64 decode to get the CRL.
    if (SUCCEEDED(hr))
    {
        BOOL bResult = CryptStringToBinary(
            (WCHAR*)pDataBase64,    // Base-64 encoded string.
            0,                      // Null-terminated.
            CRYPT_STRING_BASE64,    
            pCRL,                   // Buffer.
            &cbCRL,                 // Receives the size of the buffer. 
            NULL, NULL              // Optional.
            );
        if (!bResult)
        {
            hr = __HRESULT_FROM_WIN32(GetLastError());
        }
    }

    // Return the buffer to the caller. Caller must free the buffer.
    if (SUCCEEDED(hr))
    {
        *ppBuffer = pCRL;
        *pcbBuffer = cbCRL;
    }
    else
    {
        CoTaskMemFree(pCRL);
    }

    CoTaskMemFree(pDataBase64);
    SAFE_RELEASE(pReader);
    SAFE_RELEASE(pDrmReader);
    return hr;
}

Successivamente, l'applicazione deve verificare che la CRL sia valida. A tale scopo, verificare che il certificato CRL, che fa parte della CRL, sia firmato direttamente dal certificato radice Microsoft e abbia il valore dell'elemento SignCRL impostato su 1. Verificare anche la firma del CRL.

Dopo aver verificato la CRL, l'applicazione può archiviarla. Il numero di versione CRL deve essere controllato anche prima di archiviare in modo che l'applicazione archivia sempre la versione più recente.

La CRL ha il formato seguente.

Sezione Contenuto
Intestazione Numero di voci CRL a 32 bit versione32 bit
Voci di revoca Più voci di revoche a 160 bit
Certificato Certificato a 32 bit lengthVariable-length
Firma Firma a 8 bit type16-bit signature lengthVariable-length

 

Nota

Tutti i valori integer sono senza segno e sono rappresentati nella notazione big-endian (ordine byte di rete).

 

Descrizioni della sezione CRL

Intestazione

L'intestazione contiene il numero di versione della CRL e il numero di voci di revoche nel CRL. Una CRL può contenere zero o più voci.

Voci di revoca

Ogni voce di revoca è il digest a 160 bit di un certificato revocato. Confrontare questo digest con l'elemento DigestValue all'interno del certificato.

Certificato

La sezione del certificato contiene un valore a 32 bit che indica la lunghezza (in byte) del certificato XML e della relativa catena di certificati, insieme a una matrice di byte che contiene sia il certificato XML dell'autorità di certificazione (CA) che la catena di certificati con Microsoft come radice. Il certificato deve essere firmato da una CA che ha l'autorità per rilasciare ICL.

Nota

Il certificato non deve essere terminato con null.

 

Firma

La sezione della firma contiene il tipo di firma e la lunghezza e la firma digitale stessa. Il tipo a 8 bit è impostato su 2 per indicare che usa SHA-1 con crittografia RSA a 1024 bit. La lunghezza è un valore a 16 bit contenente la lunghezza della firma digitale in byte. La firma digitale viene calcolata su tutte le sezioni precedenti della CRL.

La firma viene calcolata usando lo schema di firma digitale RSASSA-PSS definito in PKCS #1 (versione 2.1). La funzione hash è SHA-1, definita in Federal Information Processing Standard (FIPS) 180-2 e la funzione di generazione maschera è MGF1, definita nella sezione B.2.1 in PKCS #1 (versione 2.1). Le operazioni RSASP1 e RSAVP1 usano RSA con un modulo a 1024 bit con un esponente di verifica 65537.

Uso del protocollo COPP (Certified Output Protection Protocol)