Encryptor
This is a utility program to encrypt the data using the wrapped DEK retrieved from KBS.
Build
go build encrypt.go
Requires Go 1.21 or newer. See https://go.dev/doc/install for installation of Go.
Usage
encrypt <data_file> <private_key_file> <wrapped_dek_file>
Data Encryption Steps
Generate RSA key-pair using openssl
openssl genrsa -out keypair.pem 2048
openssl rsa -in keypair.pem -pubout -out public.crt
Get DEK from KBS using public key
[!Note]
Get the auth token from KBS before requesting dek.
POST
"Accept" : "application/json"
"Content-Type" : "application/x-pem-file"
"Authorization": "Bearer <token>"
-
Data Params:
public-key=[string]
-
Request Body:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0NTXPU3AojKVDVuKyRDk
QSm7AQF+2NXdOOgOaNQrvY/38gT8YP3HM0tpvRvUey/nBnGMj6MvGeadIzuYZOm8
H2F8nMuPbWy+zw6NgUdyrpvbduUCw3Lkgf+VqdpiQjGWMIQV5TzhUwZRNfz2VSom
sIbG6r4QivDpi9MOWvfreBXCzCRcyQ2y5gyxp4/Cm/WQwF6kKQhL1p/WWkdF9TiB
VxFAxP39G/D+lg/QKKX95rDGOJipn2a0ud0P+YnXbVsSU3BP3sdxHVUF/0Wha+/2
j0uNjOws7Pdxs1heyMB1D4nJOKdwRtS1RyC9fscznq4rlaJ6CYyyE07BCmzbJK2a
NQIDAQAB
-----END PUBLIC KEY-----
-
Success Response:
-
Error Response:
Save the wrapped DEK from KBS in a file for running encryption tool later.
Encrypt data
Execute encrypt binary with required args
./encrypt diabetes-linreg.model keypair.pem wrapped.key
Security Considerations
- This encryption tool needs to be run in a secure environment. In real world, encryption operation happens on enterprise side.
- Make sure to remove the data file and private key post running encryptor.