/* Retrieve the Key Usage from one X.509 certificate. */
BOOLEAN EFIAPI X509GetKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINTN *Usage)
/* Retrieve the Key Usage from one X.509 certificate. */
BOOLEAN EFIAPI X509GetKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINTN *Usage)
{
  BOOLEAN  Status;
  X509     *X509Cert;
  if ((Cert == NULL) || (Usage == NULL)) {
    return FALSE;
  }
  X509Cert = NULL;
  Status   = FALSE;
  Status = X509ConstructCertificate (Cert, CertSize, (UINT8 **)&X509Cert);
  if ((X509Cert == NULL) || (!Status)) {
    goto _Exit;
  }
  *Usage = X509_get_key_usage (X509Cert);
  if (*Usage == NID_undef) {
    goto _Exit;
  }
  Status = TRUE;
_Exit:
  if (X509Cert != NULL) {
    X509_free (X509Cert);
  }
  return Status;
}