Skip to content

Commit 0fbfc11

Browse files
committed
Added command to verify openssl cipher and better formatting.
1 parent 7a07e99 commit 0fbfc11

File tree

1 file changed

+26
-15
lines changed
  • security/security-design/shared-assets/kms-import-keys

1 file changed

+26
-15
lines changed

security/security-design/shared-assets/kms-import-keys/README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,50 @@ This example is for an RSA 2048 Asynchronous Key to be imported in OCI Vault. Th
1515

1616
## Prerequisites
1717

18-
- 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. If you create an OCI Compute based on Oracle Linux 9, it should work immediately.
18+
- 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. If you create an OCI Compute based on Oracle Linux 9, it should work immediately. Below commandline can be used to test if your openssl version is usable.
19+
```
20+
openssl enc -id-aes256-wrap-pad -iv A65959A6 -K AABBCCDDEEFFAABBCCDDEEFFAABBCCDDEEAABBCCDDEEAABBCCDDEEFFAABBCCDD -in /dev/null
21+
```
22+
If the command returns an Error, please use and Oracle Linux 9 compute image or follow this [documentation](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/KeyManagement/Tasks/importing_assymetric_keys.htm).
1923

2024
- Get a RSA 2048 Key Pair to import and store in the file name ```my_keypair.pem```, or generate one via this command:
21-
22-
```openssl genrsa -out my_keypair.pem 2048```
25+
```
26+
openssl genrsa -out my_keypair.pem 2048
27+
```
2328

2429
- 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```
2530

2631
### Manually create the wrapped key material to be imported
2732

2833
1. Create a temporary AES key:
29-
30-
```openssl rand -out temp_aes.key 32```
34+
```
35+
openssl rand -out temp_aes.key 32
36+
```
3137

3238
2. Wrap the temporary AES key with the public wrapping key using RSA-OAEP with SHA-256:
33-
34-
```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```
39+
```
40+
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
41+
```
3542

3643
3. Generate hexadecimal of the temporary AES key material:
37-
38-
```export temporary_AES_key_hexdump=$(hexdump -v -e '/1 "%02x"' < temp_aes.key)```
44+
```
45+
export temporary_AES_key_hexdump=$(hexdump -v -e '/1 "%02x"' < temp_aes.key)
46+
```
3947

4048
4. If the RSA private key you want to import is in PEM format, convert it to DER:
41-
42-
```openssl pkcs8 -topk8 -nocrypt -inform PEM -outform DER -in my_keypair.pem -out my_private_key.key```
49+
```
50+
openssl pkcs8 -topk8 -nocrypt -inform PEM -outform DER -in my_keypair.pem -out my_private_key.key
51+
```
4352

4453
5. Wrap your RSA private key with the temporary AES key:
45-
46-
```openssl enc -id-aes256-wrap-pad -iv A65959A6 -K $temporary_AES_key_hexdump -in my_private_key.key -out my_wrapped.key```
54+
```
55+
openssl enc -id-aes256-wrap-pad -iv A65959A6 -K $temporary_AES_key_hexdump -in my_private_key.key -out my_wrapped.key
56+
```
4757

4858
6. Create the wrapped key material by concatenating both wrapped keys:
49-
50-
```cat wrapped_temp_aes.key my_wrapped.key > wrapped_key_material.key```
59+
```
60+
cat wrapped_temp_aes.key my_wrapped.key > wrapped_key_material.key
61+
```
5162

5263
### Use the provided script to generate the wrapped key material to be imported
5364

0 commit comments

Comments
 (0)