Skip to content

Commit

Permalink
fix: remove transformer specific files and code from m2k core
Browse files Browse the repository at this point in the history
Signed-off-by: Mehant Kammakomati <kmehant@gmail.com>
  • Loading branch information
kmehant committed Sep 16, 2022
1 parent 7a58987 commit 0b2f63e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 53 deletions.
4 changes: 0 additions & 4 deletions assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 0 additions & 34 deletions assets/ibm-hyper-protect-container-runtime-1-0-s390x-4-encrypt.crt

This file was deleted.

14 changes: 4 additions & 10 deletions common/cryptoutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions filesystem/templatecopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 0b2f63e

Please sign in to comment.