VirtualBox

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

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: key-internal.h 73665 2018-08-14 17:49:23Z vboxsync $ */
2/** @file
3 * IPRT - Crypto - Cryptographic Keys, Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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
28#ifndef ___common_crypto_keys_internal_h
29#define ___common_crypto_keys_internal_h
30
31#include <iprt/crypto/key.h>
32#include <iprt/bignum.h>
33
34
35/**
36 * Cryptographic key - core bits.
37 */
38typedef struct RTCRKEYINT
39{
40 /** Magic value (RTCRKEYINT_MAGIC). */
41 uint32_t u32Magic;
42 /** Reference counter. */
43 uint32_t volatile cRefs;
44 /** The key type. */
45 RTCRKEYTYPE enmType;
46 /** Flags, RTCRKEYINT_F_XXX. */
47 uint32_t fFlags;
48 /** Number of bits in the key. */
49 uint32_t cBits;
50
51#if defined(IPRT_WITH_OPENSSL)
52 /** Size of raw key copy. */
53 uint32_t cbEncoded;
54 /** Raw copy of the key, for openssl and such.
55 * If sensitive, this is a safer allocation, otherwise it follows the structure. */
56 uint8_t *pbEncoded;
57#endif
58
59 /** Type specific data. */
60 union
61 {
62 /** RTCRKEYTYPE_RSA_PRIVATE. */
63 struct
64 {
65 /** The modulus. */
66 RTBIGNUM Modulus;
67 /** The private exponent. */
68 RTBIGNUM PrivateExponent;
69 /** The public exponent. */
70 RTBIGNUM PublicExponent;
71 /** @todo add more bits as needed. */
72 } RsaPrivate;
73
74 /** RTCRKEYTYPE_RSA_PUBLIC. */
75 struct
76 {
77 /** The modulus. */
78 RTBIGNUM Modulus;
79 /** The exponent. */
80 RTBIGNUM Exponent;
81 } RsaPublic;
82 } u;
83} RTCRKEYINT;
84/** Pointer to a crypographic key. */
85typedef RTCRKEYINT *PRTCRKEYINT;
86/** Pointer to a const crypographic key. */
87typedef RTCRKEYINT const *PCRTCRKEYINT;
88
89
90
91/** @name RTCRKEYINT_F_XXX.
92 * @{ */
93/** Key contains sensitive information, so no unnecessary copies. */
94#define RTCRKEYINT_F_SENSITIVE UINT32_C(0x00000001)
95/** Set if private key bits are present. */
96#define RTCRKEYINT_F_PRIVATE UINT32_C(0x00000002)
97/** Set if public key bits are present. */
98#define RTCRKEYINT_F_PUBLIC UINT32_C(0x00000004)
99/** @} */
100
101DECLHIDDEN(int) rtCrKeyCreateWorker(PRTCRKEYINT *ppThis, RTCRKEYTYPE enmType, uint32_t fFlags,
102 void const *pvEncoded, uint32_t cbEncoded);
103DECLHIDDEN(int) rtCrKeyCreateRsaPublic(PRTCRKEY phKey, const void *pvKeyBits, uint32_t cbKeyBits,
104 PRTERRINFO pErrInfo, const char *pszErrorTag);
105DECLHIDDEN(int) rtCrKeyCreateRsaPrivate(PRTCRKEY phKey, const void *pvKeyBits, uint32_t cbKeyBits,
106 PRTERRINFO pErrInfo, const char *pszErrorTag);
107
108#endif
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