Skip to content

Commit

Permalink
updating argument names in wasm and sharedlib
Browse files Browse the repository at this point in the history
  • Loading branch information
shibme committed Jun 28, 2024
1 parent 4cec251 commit 812a668
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/sharedlib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func xipherGetPublicKey(secretKeyOrPassword *C.char, quantumSafe C.int, publicKe
}
}

func xipherEncryptData(key *C.char, data *C.char, cipherText **C.char, cipherTextLength *C.int, errMessage **C.char, errLength *C.int) {
func xipherEncryptData(keyOrPassword *C.char, data *C.char, cipherText **C.char, cipherTextLength *C.int, errMessage **C.char, errLength *C.int) {
dataBytes := C.GoBytes(unsafe.Pointer(data), C.int(len(C.GoString(data))))
if ct, err := utils.EncryptData(C.GoString(key), dataBytes); err != nil {
if ct, err := utils.EncryptData(C.GoString(keyOrPassword), dataBytes); err != nil {
*cipherText = nil
*cipherTextLength = 0
*errMessage = C.CString(err.Error())
Expand Down
6 changes: 3 additions & 3 deletions internal/sharedlib/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func XipherGetPublicKey(secretKeyOrPassword *C.char, quantumSafe C.int, publicKe
xipherGetPublicKey(secretKeyOrPassword, quantumSafe, publicKey, publicKeyLength, errMessage, errLength)
}

// XipherEncryptData encrypts data with a given public key
// XipherEncryptData encrypts data with a given public key, secret key or password
//
//export XipherEncryptData
func XipherEncryptData(publicKey *C.char, data *C.char, cipherText **C.char, cipherTextLength *C.int, errMessage **C.char, errLength *C.int) {
xipherEncryptData(publicKey, data, cipherText, cipherTextLength, errMessage, errLength)
func XipherEncryptData(keyOrPassword *C.char, data *C.char, cipherText **C.char, cipherTextLength *C.int, errMessage **C.char, errLength *C.int) {
xipherEncryptData(keyOrPassword, data, cipherText, cipherTextLength, errMessage, errLength)
}

// XipherDecryptData decrypts data with a given secret key or password
Expand Down
4 changes: 2 additions & 2 deletions internal/wasm/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func getPublicKey() js.Func {
func encryptStr() js.Func {
jsonFunc := js.FuncOf(func(this js.Value, args []js.Value) any {
if len(args) != 2 {
return jsReturn(nil, fmt.Errorf("Supported arguments: public key (required), message (required)"))
return jsReturn(nil, fmt.Errorf("Supported arguments: public key, secret key or password (required), message (required)"))
}
pk := args[0].String()
message := args[1].String()
Expand All @@ -77,7 +77,7 @@ func encryptStr() js.Func {
func decryptStr() js.Func {
jsonFunc := js.FuncOf(func(this js.Value, args []js.Value) any {
if len(args) != 2 {
return jsReturn(nil, fmt.Errorf("Supported arguments: secret key (required), ciphertext (required)"))
return jsReturn(nil, fmt.Errorf("Supported arguments: secret key or password (required), ciphertext (required)"))
}
secret := args[0].String()
ciphertext := args[1].String()
Expand Down

0 comments on commit 812a668

Please sign in to comment.