Skip to content

Commit f7ad647

Browse files
committed
Initial version
1 parent 12c4d89 commit f7ad647

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Importing keys into OCI KMS Vaults
2+
3+
Owner: Leon van Birgelen
4+
5+
Key Management Service is an OCI service that stores and manages keys for secure access to resources.
6+
7+
The Oracle Cloud Infrastructure (OCI) [Key Management Service](https://oracle.com/security/cloud-security/key-management/) (KMS) is a cloud-based service that provides centralized management and control of encryption keys for data stored in OCI.
8+
9+
One of the capabilities of OCI KMS is to import Vault Keys and Key Versions, in case you want to "bring your own key" (BYOK). There is [detailed documentation](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/KeyManagement/Tasks/importingkeys.htm) available on this process but in this example below you will find a brief guide on how to this as it is a tedious and detailed process.
10+
11+
This example is for a RSA 2048 Asynchronous key to be imported.
12+
13+
# Prerequisites
14+
15+
- Make sure to have a up-to-date version of OpenSSL installed that supports the RSA_OAEP_AES_SHA256 wrapping mechanism. OCI CloudShell is currently based on Oracle Linux 7, which does not have the minimum required version of OpenSSL installed.
16+
17+
- Get a RSA 2048 Key Pair to import and store in the file name **my_keypair.pem**, or generate one via this command:
18+
19+
```openssl genrsa -out my_keypair.pem 2048```
20+
21+
# Create the wrapped key material to be imported
22+
23+
1. Create an OCI Vault and copy the Public Wrapping Key. You can find it when creating a new Key in the Vault and enabling the "Import External key" checkbox. For this example store the wrapping key in file called **pub_wrapping_key.pem**
24+
25+
2. Create a temporary AES key:
26+
27+
```openssl rand -out temp_aes.key 32```
28+
29+
3. Wrap the temporary AES Key:
30+
31+
```openssl pkeyutl -encrypt -in temp_aes.key -inkey pub_wrapping_key.pem -pubin -out wrapped_temp_aes.key -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256```
32+
33+
4. Create a hexdump of the temporary AES key:
34+
35+
```export temporary_AES_key_hexdump=$(hexdump -v -e '/1 "%02x"' < temp_aes.key)```
36+
37+
5. Extract the private key from the to be imported RSA key:
38+
39+
```openssl pkcs8 -topk8 -nocrypt -inform PEM -outform DER -in my_keypair.pem -out my_private_key.key```
40+
41+
6. Encrypt the private key with the temporary AES key:
42+
43+
```openssl enc -id-aes256-wrap-pad -iv A65959A6 -K $temporary_AES_key_hexdump -in my_private_key.key -out my_wrapped.key```
44+
45+
7. Concatenate the wrapped temporary AES key with the wrapped private key into the to be imported key material:
46+
47+
```cat wrapped_temp_aes.key my_wrapped.key > wrapped_key_material.key```
48+
49+
# Import the wrapped key material
50+
51+
- From the OCI Vault where the Public Wrapping Key was retrieved, create a Key and select the RSA as Key Shape Algorithm with the length 2048.
52+
- Have hte Import External key checkbox enabled.
53+
- The Wrapping Algorithm should be automatically set to "RSA_OAEP_AES_SHA256"
54+
- Upload the wrapped key material file **wrapped_key_material.key**
55+
- Click on the Create Key button.
56+
57+
# License
58+
59+
Copyright (c) 2024 Oracle and/or its affiliates.
60+
61+
Licensed under the Universal Permissive License (UPL), Version 1.0.
62+
63+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.

0 commit comments

Comments
 (0)