pkix-util.cpp revision 13493ab7596e827b8d0caab2c89e635dd65f78f9
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync/* $Id$ */
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync/** @file
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * IPRT - Crypto - Public Key Infrastructure API, Utilities.
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync */
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync/*
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * Copyright (C) 2006-2014 Oracle Corporation
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync *
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * available from http://www.virtualbox.org. This file is free software;
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * General Public License (GPL) as published by the Free Software
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync *
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * The contents of this file may alternatively be used under the terms
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * of the Common Development and Distribution License Version 1.0
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * VirtualBox OSE distribution, in which case the provisions of the
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * CDDL are applicable instead of those of the GPL.
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync *
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * You may elect to license modified versions of this file under the
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync * terms and conditions of either the GPL or the CDDL or both.
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync */
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync/*******************************************************************************
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync* Header Files *
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync*******************************************************************************/
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync#include "internal/iprt.h"
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync#include <iprt/crypto/pkix.h>
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync#include <iprt/err.h>
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync#include <iprt/string.h>
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync#ifdef IPRT_WITH_OPENSSL
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync# include "internal/iprt-openssl.h"
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync# include "openssl/evp.h"
9aa6fbc4da65d57d07aadef838a1b032bd659c0fvboxsync#endif
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsyncRTDECL(const char *) RTCrPkixGetCiperOidFromSignatureAlgorithm(PCRTASN1OBJID pAlgorithm)
bc400f01f6db80c47cf6b659a98c19c79a91159fvboxsync{
/*
* This is all hardcoded, at least for the time being.
*/
if (RTAsn1ObjId_StartsWith(pAlgorithm, RTCR_PKCS1_OID))
{
if (RTAsn1ObjIdCountComponents(pAlgorithm) == 7)
switch (RTAsn1ObjIdGetLastComponentsAsUInt32(pAlgorithm))
{
case 2:
case 3:
case 4:
case 5:
case 11:
case 12:
case 13:
case 14:
return RTCR_PKCS1_RSA_OID;
case 1: AssertFailed();
default:
return NULL;
}
}
/*
* OIW oddballs.
*/
else if (RTAsn1ObjId_StartsWith(pAlgorithm, "1.3.14.3.2"))
{
if (RTAsn1ObjIdCountComponents(pAlgorithm) == 6)
switch (RTAsn1ObjIdGetLastComponentsAsUInt32(pAlgorithm))
{
case 11:
case 14:
case 15:
case 24:
case 25:
case 29:
return RTCR_PKCS1_RSA_OID;
default:
return NULL;
}
}
return NULL;
}