VirtualBox

source: vbox/trunk/include/iprt/crypto/key.h@ 74295

Last change on this file since 74295 was 74295, checked in by vboxsync, 6 years ago

IPRT/crypto: Wrapped SSL, alleged RC4, and RSA key generation. Added methods for quering someRSA key components. Exposed big numbers, x509 and asn1 APIs as stable. bugref:9246

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/** @file
2 * IPRT - Cryptographic Keys
3 */
4
5/*
6 * Copyright (C) 2006-2018 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_crypto_key_h
27#define ___iprt_crypto_key_h
28
29#include <iprt/crypto/x509.h>
30#include <iprt/crypto/taf.h>
31#include <iprt/sha.h>
32
33
34RT_C_DECLS_BEGIN
35
36struct RTCRPEMSECTION;
37struct RTCRX509SUBJECTPUBLICKEYINFO;
38
39/** @defgroup grp_rt_crkey RTCrKey - Crypotgraphic Keys.
40 * @ingroup grp_rt_crypto
41 * @{
42 */
43
44/**
45 * Key types.
46 */
47typedef enum RTCRKEYTYPE
48{
49 /** Invalid zero value. */
50 RTCRKEYTYPE_INVALID = 0,
51 /** RSA private key. */
52 RTCRKEYTYPE_RSA_PRIVATE,
53 /** RSA public key. */
54 RTCRKEYTYPE_RSA_PUBLIC,
55 /** End of key types. */
56 RTCRKEYTYPE_END,
57 /** The usual type size hack. */
58 RTCRKEYTYPE_32BIT_HACK = 0x7fffffff
59} RTCRKEYTYPE;
60
61
62RTDECL(int) RTCrKeyCreateFromSubjectPublicKeyInfo(PRTCRKEY phKey, struct RTCRX509SUBJECTPUBLICKEYINFO const *pSrc,
63 PRTERRINFO pErrInfo, const char *pszErrorTag);
64RTDECL(int) RTCrKeyCreateFromPublicAlgorithmAndBits(PRTCRKEY phKey, PCRTASN1OBJID pAlgorithm,
65 PCRTASN1BITSTRING pPublicKey,
66 PRTERRINFO pErrInfo, const char *pszErrorTag);
67RTDECL(int) RTCrKeyCreateFromPemSection(PRTCRKEY phKey, uint32_t fFlags, struct RTCRPEMSECTION const *pSection,
68 const char *pszPassword, PRTERRINFO pErrInfo, const char *pszErrorTag);
69RTDECL(int) RTCrKeyCreateFromBuffer(PRTCRKEY phKey, uint32_t fFlags, void const *pvSrc, size_t cbSrc,
70 const char *pszPassword, PRTERRINFO pErrInfo, const char *pszErrorTag);
71RTDECL(int) RTCrKeyCreateFromFile(PRTCRKEY phKey, uint32_t fFlags, const char *pszFilename,
72 const char *pszPassword, PRTERRINFO pErrInfo);
73/** @todo add support for decrypting private keys. */
74/** @name RTCRKEYFROM_F_XXX
75 * @{ */
76/** Only PEM sections, no binary fallback.
77 * @sa RTCRPEMREADFILE_F_ONLY_PEM */
78#define RTCRKEYFROM_F_ONLY_PEM RT_BIT(1)
79/** Valid flags. */
80#define RTCRKEYFROM_F_VALID_MASK UINT32_C(0x00000002)
81/** @} */
82
83RTDECL(int) RTCrKeyCreateNewRsa(PRTCRKEY phKey, uint32_t cBits, uint32_t uPubExp, uint32_t fFlags);
84
85
86RTDECL(uint32_t) RTCrKeyRetain(RTCRKEY hKey);
87RTDECL(uint32_t) RTCrKeyRelease(RTCRKEY hKey);
88RTDECL(RTCRKEYTYPE) RTCrKeyGetType(RTCRKEY hKey);
89RTDECL(bool) RTCrKeyHasPrivatePart(RTCRKEY hKey);
90RTDECL(bool) RTCrKeyHasPublicPart(RTCRKEY hKey);
91RTDECL(uint32_t) RTCrKeyGetBitCount(RTCRKEY hKey);
92RTDECL(int) RTCrKeyQueryRsaModulus(RTCRKEY hKey, PRTBIGNUM pModulus);
93RTDECL(int) RTCrKeyQueryRsaPrivateExponent(RTCRKEY hKey, PRTBIGNUM pPrivateExponent);
94
95/** Public key markers. */
96extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyPublicMarkers[];
97/** Number of entries in g_aRTCrKeyPublicMarkers. */
98extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyPublicMarkers;
99/** Private key markers. */
100extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyPrivateMarkers[];
101/** Number of entries in g_aRTCrKeyPrivateMarkers. */
102extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyPrivateMarkers;
103/** Private and public key markers. */
104extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyAllMarkers[];
105/** Number of entries in g_aRTCrKeyAllMarkers. */
106extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyAllMarkers;
107
108/** @} */
109
110RT_C_DECLS_END
111
112#endif
113
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette