VirtualBox

source: vbox/trunk/include/iprt/crypto/rsa.h@ 94480

Last change on this file since 94480 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/** @file
2 * IPRT - Crypto - RSA Public Key Cryptosystem .
3 */
4
5/*
6 * Copyright (C) 2006-2022 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_rsa_h
27#define IPRT_INCLUDED_crypto_rsa_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/asn1.h>
33#include <iprt/crypto/x509.h>
34#include <iprt/crypto/pkcs7.h>
35#include <iprt/md5.h>
36#include <iprt/sha.h>
37
38
39RT_C_DECLS_BEGIN
40
41/** @defgroup grp_rt_cr_rsa RTCrRsa - RSA Public Key Cryptosystem
42 * @ingroup grp_rt_crypto
43 * @{
44 */
45
46/**
47 * RSA public key - ASN.1 IPRT representation.
48 */
49typedef struct RTCRRSAPUBLICKEY
50{
51 /** Sequence core for the structure. */
52 RTASN1SEQUENCECORE SeqCore;
53 /** The modulus (n). */
54 RTASN1INTEGER Modulus;
55 /** The public exponent (e). */
56 RTASN1INTEGER PublicExponent;
57} RTCRRSAPUBLICKEY;
58/** Pointer to the ASN.1 IPRT representation of an RSA public key. */
59typedef RTCRRSAPUBLICKEY *PRTCRRSAPUBLICKEY;
60/** Pointer to the const ASN.1 IPRT representation of an RSA public key. */
61typedef RTCRRSAPUBLICKEY const *PCRTCRRSAPUBLICKEY;
62RTASN1TYPE_STANDARD_PROTOTYPES(RTCRRSAPUBLICKEY, RTDECL, RTCrRsaPublicKey, SeqCore.Asn1Core);
63
64RTDECL(bool) RTCrRsaPublicKey_CanHandleDigestType(PCRTCRRSAPUBLICKEY pRsaPublicKey, RTDIGESTTYPE enmDigestType,
65 PRTERRINFO pErrInfo);
66
67
68/**
69 * RSA other prime info (ASN.1 IPRT representation).
70 */
71typedef struct RTCRRSAOTHERPRIMEINFO
72{
73 /** Sequence core for the structure. */
74 RTASN1SEQUENCECORE SeqCore;
75 /** The prime (ri). */
76 RTASN1INTEGER Prime;
77 /** The exponent (di). */
78 RTASN1INTEGER Exponent;
79 /** The coefficient (ti). */
80 RTASN1INTEGER Coefficient;
81} RTCRRSAOTHERPRIMEINFO;
82/** Pointer to the ASN.1 IPRT representation of RSA other prime info. */
83typedef RTCRRSAOTHERPRIMEINFO *PRTCRRSAOTHERPRIMEINFO;
84/** Pointer to the const ASN.1 IPRT representation of RSA other prime info. */
85typedef RTCRRSAOTHERPRIMEINFO const *PCRTCRRSAOTHERPRIMEINFO;
86RTASN1TYPE_STANDARD_PROTOTYPES(RTCRRSAOTHERPRIMEINFO, RTDECL, RTCrRsaOtherPrimeInfo, SeqCore.Asn1Core);
87RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRRSAOTHERPRIMEINFOS, RTCRRSAOTHERPRIMEINFO, RTDECL, RTCrRsaOtherPrimeInfos);
88
89/**
90 * RSA private key - ASN.1 IPRT representation.
91 */
92typedef struct RTCRRSAPRIVATEKEY
93{
94 /** Sequence core for the structure. */
95 RTASN1SEQUENCECORE SeqCore;
96 /** Key version number. */
97 RTASN1INTEGER Version;
98 /** The modulus (n). */
99 RTASN1INTEGER Modulus;
100 /** The public exponent (e). */
101 RTASN1INTEGER PublicExponent;
102 /** The private exponent (d). */
103 RTASN1INTEGER PrivateExponent;
104 /** The first prime factor (p) of the modulus (n). */
105 RTASN1INTEGER Prime1;
106 /** The second prime factor (q) of the modulus (n). */
107 RTASN1INTEGER Prime2;
108 /** The first exponent (d mod (p-1)). */
109 RTASN1INTEGER Exponent1;
110 /** The second exponent (d mod (q-1)). */
111 RTASN1INTEGER Exponent2;
112 /** The coefficient ((inverse of q) mod p). */
113 RTASN1INTEGER Coefficient;
114 /** Optional other prime information (version must be 'multi' if present). */
115 RTCRRSAOTHERPRIMEINFOS OtherPrimeInfos;
116} RTCRRSAPRIVATEKEY;
117/** Pointer to the ASN.1 IPRT representation of an RSA private key. */
118typedef RTCRRSAPRIVATEKEY *PRTCRRSAPRIVATEKEY;
119/** Pointer to the const ASN.1 IPRT representation of an RSA private key. */
120typedef RTCRRSAPRIVATEKEY const *PCRTCRRSAPRIVATEKEY;
121RTASN1TYPE_STANDARD_PROTOTYPES(RTCRRSAPRIVATEKEY, RTDECL, RTCrRsaPrivateKey, SeqCore.Asn1Core);
122
123/** @name RSA Private Key Versions
124 * @{ */
125#define RTCRRSAPRIVATEKEY_VERSION_TWO_PRIME 0
126#define RTCRRSAPRIVATEKEY_VERSION_MULTI 1
127/** @} */
128
129RTDECL(bool) RTCrRsaPrivateKey_CanHandleDigestType(PCRTCRRSAPRIVATEKEY pRsaPrivateKey, RTDIGESTTYPE enmDigestType,
130 PRTERRINFO pErrInfo);
131
132
133/**
134 * RSA DigestInfo used by the EMSA-PKCS1-v1_5 encoding method.
135 */
136typedef struct RTCRRSADIGESTINFO
137{
138 /** Sequence core for the structure. */
139 RTASN1SEQUENCECORE SeqCore;
140 /** The digest algorithm. */
141 RTCRX509ALGORITHMIDENTIFIER DigestAlgorithm;
142 /** The digest. */
143 RTASN1OCTETSTRING Digest;
144} RTCRRSADIGESTINFO;
145/** Pointer to the ASN.1 IPRT representation of RSA digest info. */
146typedef RTCRRSADIGESTINFO *PRTCRRSADIGESTINFO;
147/** Pointer to the const ASN.1 IPRT representation of RSA digest info. */
148typedef RTCRRSADIGESTINFO const *PCRTCRRSADIGESTINFO;
149RTASN1TYPE_STANDARD_PROTOTYPES(RTCRRSADIGESTINFO, RTDECL, RTCrRsaDigestInfo, SeqCore.Asn1Core);
150
151/** @} */
152
153RT_C_DECLS_END
154
155#endif /* !IPRT_INCLUDED_crypto_rsa_h */
156
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