VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/crypto/key-internal.h@ 78198

Last change on this file since 78198 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: 3.8 KB
Line 
1/* $Id: key-internal.h 76585 2019-01-01 06:31:29Z vboxsync $ */
2/** @file
3 * IPRT - Crypto - Cryptographic Keys, Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_SRC_common_crypto_key_internal_h
28#define IPRT_INCLUDED_SRC_common_crypto_key_internal_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/crypto/key.h>
34#include <iprt/bignum.h>
35
36
37/**
38 * Cryptographic key - core bits.
39 */
40typedef struct RTCRKEYINT
41{
42 /** Magic value (RTCRKEYINT_MAGIC). */
43 uint32_t u32Magic;
44 /** Reference counter. */
45 uint32_t volatile cRefs;
46 /** The key type. */
47 RTCRKEYTYPE enmType;
48 /** Flags, RTCRKEYINT_F_XXX. */
49 uint32_t fFlags;
50 /** Number of bits in the key. */
51 uint32_t cBits;
52
53#if defined(IPRT_WITH_OPENSSL)
54 /** Size of raw key copy. */
55 uint32_t cbEncoded;
56 /** Raw copy of the key, for openssl and such.
57 * If sensitive, this is a safer allocation, otherwise it follows the structure. */
58 uint8_t *pbEncoded;
59#endif
60
61 /** Type specific data. */
62 union
63 {
64 /** RTCRKEYTYPE_RSA_PRIVATE. */
65 struct
66 {
67 /** The modulus. */
68 RTBIGNUM Modulus;
69 /** The private exponent. */
70 RTBIGNUM PrivateExponent;
71 /** The public exponent. */
72 RTBIGNUM PublicExponent;
73 /** @todo add more bits as needed. */
74 } RsaPrivate;
75
76 /** RTCRKEYTYPE_RSA_PUBLIC. */
77 struct
78 {
79 /** The modulus. */
80 RTBIGNUM Modulus;
81 /** The exponent. */
82 RTBIGNUM Exponent;
83 } RsaPublic;
84 } u;
85} RTCRKEYINT;
86/** Pointer to a crypographic key. */
87typedef RTCRKEYINT *PRTCRKEYINT;
88/** Pointer to a const crypographic key. */
89typedef RTCRKEYINT const *PCRTCRKEYINT;
90
91
92
93/** @name RTCRKEYINT_F_XXX.
94 * @{ */
95/** Key contains sensitive information, so no unnecessary copies. */
96#define RTCRKEYINT_F_SENSITIVE UINT32_C(0x00000001)
97/** Set if private key bits are present. */
98#define RTCRKEYINT_F_PRIVATE UINT32_C(0x00000002)
99/** Set if public key bits are present. */
100#define RTCRKEYINT_F_PUBLIC UINT32_C(0x00000004)
101/** @} */
102
103DECLHIDDEN(int) rtCrKeyCreateWorker(PRTCRKEYINT *ppThis, RTCRKEYTYPE enmType, uint32_t fFlags,
104 void const *pvEncoded, uint32_t cbEncoded);
105DECLHIDDEN(int) rtCrKeyCreateRsaPublic(PRTCRKEY phKey, const void *pvKeyBits, uint32_t cbKeyBits,
106 PRTERRINFO pErrInfo, const char *pszErrorTag);
107DECLHIDDEN(int) rtCrKeyCreateRsaPrivate(PRTCRKEY phKey, const void *pvKeyBits, uint32_t cbKeyBits,
108 PRTERRINFO pErrInfo, const char *pszErrorTag);
109
110#endif /* !IPRT_INCLUDED_SRC_common_crypto_key_internal_h */
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