VirtualBox

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

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

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/** @file
2 * IPRT - Cryptographic Keys
3 */
4
5/*
6 * Copyright (C) 2006-2019 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_INCLUDED_crypto_key_h
27#define IPRT_INCLUDED_crypto_key_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/crypto/x509.h>
33#include <iprt/crypto/taf.h>
34#include <iprt/sha.h>
35
36
37RT_C_DECLS_BEGIN
38
39struct RTCRPEMSECTION;
40struct RTCRX509SUBJECTPUBLICKEYINFO;
41
42/** @defgroup grp_rt_crkey RTCrKey - Crypotgraphic Keys.
43 * @ingroup grp_rt_crypto
44 * @{
45 */
46
47/**
48 * Key types.
49 */
50typedef enum RTCRKEYTYPE
51{
52 /** Invalid zero value. */
53 RTCRKEYTYPE_INVALID = 0,
54 /** RSA private key. */
55 RTCRKEYTYPE_RSA_PRIVATE,
56 /** RSA public key. */
57 RTCRKEYTYPE_RSA_PUBLIC,
58 /** End of key types. */
59 RTCRKEYTYPE_END,
60 /** The usual type size hack. */
61 RTCRKEYTYPE_32BIT_HACK = 0x7fffffff
62} RTCRKEYTYPE;
63
64
65RTDECL(int) RTCrKeyCreateFromSubjectPublicKeyInfo(PRTCRKEY phKey, struct RTCRX509SUBJECTPUBLICKEYINFO const *pSrc,
66 PRTERRINFO pErrInfo, const char *pszErrorTag);
67RTDECL(int) RTCrKeyCreateFromPublicAlgorithmAndBits(PRTCRKEY phKey, PCRTASN1OBJID pAlgorithm,
68 PCRTASN1BITSTRING pPublicKey,
69 PRTERRINFO pErrInfo, const char *pszErrorTag);
70RTDECL(int) RTCrKeyCreateFromPemSection(PRTCRKEY phKey, uint32_t fFlags, struct RTCRPEMSECTION const *pSection,
71 const char *pszPassword, PRTERRINFO pErrInfo, const char *pszErrorTag);
72RTDECL(int) RTCrKeyCreateFromBuffer(PRTCRKEY phKey, uint32_t fFlags, void const *pvSrc, size_t cbSrc,
73 const char *pszPassword, PRTERRINFO pErrInfo, const char *pszErrorTag);
74RTDECL(int) RTCrKeyCreateFromFile(PRTCRKEY phKey, uint32_t fFlags, const char *pszFilename,
75 const char *pszPassword, PRTERRINFO pErrInfo);
76/** @todo add support for decrypting private keys. */
77/** @name RTCRKEYFROM_F_XXX
78 * @{ */
79/** Only PEM sections, no binary fallback.
80 * @sa RTCRPEMREADFILE_F_ONLY_PEM */
81#define RTCRKEYFROM_F_ONLY_PEM RT_BIT(1)
82/** Valid flags. */
83#define RTCRKEYFROM_F_VALID_MASK UINT32_C(0x00000002)
84/** @} */
85
86RTDECL(int) RTCrKeyCreateNewRsa(PRTCRKEY phKey, uint32_t cBits, uint32_t uPubExp, uint32_t fFlags);
87
88
89RTDECL(uint32_t) RTCrKeyRetain(RTCRKEY hKey);
90RTDECL(uint32_t) RTCrKeyRelease(RTCRKEY hKey);
91RTDECL(RTCRKEYTYPE) RTCrKeyGetType(RTCRKEY hKey);
92RTDECL(bool) RTCrKeyHasPrivatePart(RTCRKEY hKey);
93RTDECL(bool) RTCrKeyHasPublicPart(RTCRKEY hKey);
94RTDECL(uint32_t) RTCrKeyGetBitCount(RTCRKEY hKey);
95RTDECL(int) RTCrKeyQueryRsaModulus(RTCRKEY hKey, PRTBIGNUM pModulus);
96RTDECL(int) RTCrKeyQueryRsaPrivateExponent(RTCRKEY hKey, PRTBIGNUM pPrivateExponent);
97
98/** Public key markers. */
99extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyPublicMarkers[];
100/** Number of entries in g_aRTCrKeyPublicMarkers. */
101extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyPublicMarkers;
102/** Private key markers. */
103extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyPrivateMarkers[];
104/** Number of entries in g_aRTCrKeyPrivateMarkers. */
105extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyPrivateMarkers;
106/** Private and public key markers. */
107extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyAllMarkers[];
108/** Number of entries in g_aRTCrKeyAllMarkers. */
109extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyAllMarkers;
110
111/** @} */
112
113RT_C_DECLS_END
114
115#endif /* !IPRT_INCLUDED_crypto_key_h */
116
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