VirtualBox

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

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

IPRT,SUP,Main: Working on new crypto key handling and rsa signing. bugref:9152 [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 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 hKey, struct RTCRX509SUBJECTPUBLICKEYINFO const *pSrc,
63 PRTERRINFO pErrInfo, const char *pszErrorTag);
64RTDECL(int) RTCrKeyCreateFromPublicAlgorithmAndBits(PRTCRKEY hKey, PCRTASN1OBJID pAlgorithm,
65 PCRTASN1BITSTRING pPublicKey,
66 PRTERRINFO pErrInfo, const char *pszErrorTag);
67RTDECL(int) RTCrKeyCreateFromPemSection(PRTCRKEY hKey, uint32_t fFlags, struct RTCRPEMSECTION const *pSection,
68 PRTERRINFO pErrInfo, const char *pszErrorTag);
69RTDECL(int) RTCrKeyCreateFromBuffer(PRTCRKEY hKey, uint32_t fFlags, void const *pvSrc, size_t cbSrc,
70 PRTERRINFO pErrInfo, const char *pszErrorTag);
71RTDECL(int) RTCrKeyCreateFromFile(PRTCRKEY hKey, uint32_t fFlags, const char *pszFilename, PRTERRINFO pErrInfo);
72/** @todo add support for decrypting private keys. */
73/** @def RTCRKEYFROM_F_XXX
74 * @{ */
75/** Only PEM sections, no binary fallback.
76 * @sa RTCRPEMREADFILE_F_ONLY_PEM */
77#define RTCRKEYFROM_F_ONLY_PEM RT_BIT(1)
78/** Valid flags. */
79#define RTCRKEYFROM_F_VALID_MASK UINT32_C(0x00000002)
80/** @} */
81
82RTDECL(uint32_t) RTCrKeyRetain(RTCRKEY hKey);
83RTDECL(uint32_t) RTCrKeyRelease(RTCRKEY hKey);
84RTDECL(RTCRKEYTYPE) RTCrKeyGetType(RTCRKEY hKey);
85RTDECL(bool) RTCrKeyHasPrivatePart(RTCRKEY hKey);
86RTDECL(bool) RTCrKeyHasPublicPart(RTCRKEY hKey);
87RTDECL(uint32_t) RTCrKeyGetBitCount(RTCRKEY hKey);
88
89
90/** Public key markers. */
91extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyPublicMarkers[];
92/** Number of entries in g_aRTCrKeyPublicMarkers. */
93extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyPublicMarkers;
94/** Private key markers. */
95extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyPrivateMarkers[];
96/** Number of entries in g_aRTCrKeyPrivateMarkers. */
97extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyPrivateMarkers;
98/** Private and public key markers. */
99extern RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrKeyAllMarkers[];
100/** Number of entries in g_aRTCrKeyAllMarkers. */
101extern RT_DECL_DATA_CONST(uint32_t const) g_cRTCrKeyAllMarkers;
102
103/** @} */
104
105RT_C_DECLS_END
106
107#endif
108
109
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