From 0b2f63e71a5c6fcecc987e75b7343ce5c1ca343d Mon Sep 17 00:00:00 2001 From: Mehant Kammakomati Date: Fri, 16 Sep 2022 21:34:42 +0530 Subject: [PATCH] fix: remove transformer specific files and code from m2k core Signed-off-by: Mehant Kammakomati --- assets/assets.go | 4 --- ...-container-runtime-1-0-s390x-4-encrypt.crt | 34 ------------------- common/cryptoutils.go | 14 +++----- filesystem/templatecopy.go | 10 +++--- 4 files changed, 9 insertions(+), 53 deletions(-) delete mode 100644 assets/ibm-hyper-protect-container-runtime-1-0-s390x-4-encrypt.crt diff --git a/assets/assets.go b/assets/assets.go index 567f1b4b9..badebbf27 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -27,7 +27,3 @@ var AssetsDir embed.FS //AssetFilePermissions is embedded file having permissions information for the assets //go:embed filepermissions.yaml var AssetFilePermissions string - -//IbmHyperProtectCert is embedded file having IBM Hyper Protect encryption certificate -//go:embed ibm-hyper-protect-container-runtime-1-0-s390x-4-encrypt.crt -var IbmHyperProtectCert string diff --git a/assets/ibm-hyper-protect-container-runtime-1-0-s390x-4-encrypt.crt b/assets/ibm-hyper-protect-container-runtime-1-0-s390x-4-encrypt.crt deleted file mode 100644 index d213d46a1..000000000 --- a/assets/ibm-hyper-protect-container-runtime-1-0-s390x-4-encrypt.crt +++ /dev/null @@ -1,34 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIF8TCCA9mgAwIBAgIQLKNAizePV1jGkvBknjjfOzANBgkqhkiG9w0BAQ0FADCB -0TELMAkGA1UEBhMCREUxGzAZBgNVBAgMEkJhZGVuLVfDvHJ0dGVtYmVyZzETMBEG -A1UEBwwKQsO2YmxpbmdlbjE0MDIGA1UECgwrSUJNIERldXRzY2hsYW5kIFJlc2Vh -cmNoICYgRGV2ZWxvcG1lbnQgR21iSDEkMCIGA1UECxMbSUJNIFogSHlicmlkIENs -b3VkIFBsYXRmb3JtMTQwMgYDVQQDDCtJQk0gRGV1dHNjaGxhbmQgUmVzZWFyY2gg -J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PnuDNRe/LEshv+yeHS5Yqjgb/o5WzhHQNla6kQpD -TgbYvF70Qkj3agSH6+M6C+mmdgzGNQOWhnPBPtDiySOn8BvlhIvcsOz/OQyIi0Se -4vqiKPQmGUJ9aZCmzmkKbzUIpWJZy8XOcG15a5lW1OIDIVl7qRehZDQ0MqhYk5yQ -hXG/0o50APhSJ3fN6ulcdP/BfMGQmHs3fRHiaOMxJvJC/obUSDCgDIrBodAk2GvW -8aKEu2yRS1RoespumrkB621eULWhTQ//M31JlvBSo5daulOcjfBeCmGcQGQFJs45 -hsTkLfltYf6nkFxzrjPvaRMT9xGmXFUkMrr163P2f0ngDp2BopqAGaVT/yD4llOs -Li5o5ZEcSOhILypa141pGwDBK/7IGv35zicO39VlpKsF/sRej4xPMkZOSlBSAgQf -oDJ6NLx69TtmcDpz0nU9y4yjZQDWj2CiG8yK5Lr9ayq8ayOneJr3Krh0bJ43izD2 -19UeNHaQrN94ylMNAyNB+2QrOtkAYuu0XKYuEDYaKx5V9w0Oodc2RJVZVt4PeHyY -BxB0v4gNdfr/ESjrmwHfQJh1wQYMG6mUUHseIGKwb7qLaHIp7Nxxc1bydlxEHqqB -bF0c1daNoz1JrAL6rrhMRMT8TQZTw+n/+R3HDbdIWG9alxtNbg== ------END CERTIFICATE----- \ No newline at end of file diff --git a/common/cryptoutils.go b/common/cryptoutils.go index d3415c352..03b49201c 100644 --- a/common/cryptoutils.go +++ b/common/cryptoutils.go @@ -26,18 +26,12 @@ import ( "encoding/pem" "fmt" - "github.com/konveyor/move2kube/assets" - "github.com/sirupsen/logrus" "golang.org/x/crypto/pbkdf2" ) -// RsaCertEncryptWrapper can be used to encrypt the data using RSA PKCS1v15 algorithm with certificate as key -func RsaCertEncryptWrapper(certificate string, data string) string { - if certificate == "" { - logrus.Info("using certificate from IBM Hyper Protect Container Runtime") - certificate = assets.IbmHyperProtectCert - } +// EncryptRsaCertWrapper can be used to encrypt the data using RSA PKCS1v15 algorithm with certificate as key +func EncryptRsaCertWrapper(certificate string, data string) string { rsaPublicKey, err := getRSAPublicKeyFromCertificate([]byte(certificate)) if err != nil { @@ -52,8 +46,8 @@ func RsaCertEncryptWrapper(certificate string, data string) string { return string(out) } -// AesCbcEncryptWithPbkdfWrapper can be used to encrypt the data using AES 256 CBC mode with Pbkdf key derivation -func AesCbcEncryptWithPbkdfWrapper(key string, data string) string { +// EncryptAesCbcWithPbkdfWrapper can be used to encrypt the data using AES 256 CBC mode with Pbkdf key derivation +func EncryptAesCbcWithPbkdfWrapper(key string, data string) string { salt := make([]byte, 16) _, err := rand.Read(salt) if err != nil { diff --git a/filesystem/templatecopy.go b/filesystem/templatecopy.go index 81c3083d5..71453678c 100644 --- a/filesystem/templatecopy.go +++ b/filesystem/templatecopy.go @@ -146,8 +146,8 @@ func templateCopyDeletionCallBack(source, destination string, addOnConfigAsIface return nil } -// execTpl executes the template and returns the filled template -func execTpl(t *template.Template) func(string, interface{}) (string, error) { +// execTemplate executes the template and returns the filled template +func execTemplate(t *template.Template) func(string, interface{}) (string, error) { return func(name string, v interface{}) (string, error) { var buf strings.Builder err := t.ExecuteTemplate(&buf, name, v) @@ -166,9 +166,9 @@ func writeTemplateToFile(tpl string, config interface{}, writepath string, packageTemplate := template.New("") var err error methodMap := template.FuncMap{ - "execTpl": execTpl(packageTemplate), - "aesCbcPbkdfEnc": common.AesCbcEncryptWithPbkdfWrapper, - "rsaCertEnc": common.RsaCertEncryptWrapper, + "execTemplate": execTemplate(packageTemplate), + "EncAesCbcPbkdf": common.EncryptAesCbcWithPbkdfWrapper, + "EncRsaCert": common.EncryptRsaCertWrapper, } template.Must(packageTemplate.Delims(openingDelimiter, closingDelimiter).Funcs(sprig.TxtFuncMap()).Funcs(methodMap).Parse(tpl)) if err != nil {