Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ocrypto/asym_decryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ type ECDecryptor struct {
}

func NewECDecryptor(sk *ecdh.PrivateKey) (ECDecryptor, error) {
// TK Make these reasonable? IIRC salt should be longer, info maybe a parameters?
salt := []byte("salt")
// TK Move salt and info out of library, into API option functions
digest := sha256.New()
digest.Write([]byte("TDF"))
salt := digest.Sum(nil)

return ECDecryptor{sk, salt, nil}, nil
}

Expand Down
6 changes: 4 additions & 2 deletions lib/ocrypto/asym_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ func FromPublicPEM(publicKeyInPem string) (PublicKeyEncryptor, error) {

func newECIES(pub *ecdh.PublicKey) (ECEncryptor, error) {
ek, err := pub.Curve().GenerateKey(rand.Reader)
// TK Make these reasonable? IIRC salt should be longer, info maybe a parameters?
salt := []byte("salt")
// TK Move salt and info out of library, into API option functions
digest := sha256.New()
digest.Write([]byte("TDF"))
salt := digest.Sum(nil)
return ECEncryptor{pub, ek, salt, nil}, err
}

Expand Down
7 changes: 6 additions & 1 deletion sdk/kas_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sdk

import (
"context"
"crypto/sha256"
"errors"
"fmt"
"net"
Expand Down Expand Up @@ -194,7 +195,11 @@ func (k *KASClient) handleECKeyResponse(response *kas.RewrapResponse) (map[strin
if err != nil {
return nil, fmt.Errorf("ocrypto.ComputeECDHKey failed: %w", err)
}
sessionKey, err := ocrypto.CalculateHKDF([]byte("salt"), ecdhKey)

digest := sha256.New()
digest.Write([]byte("TDF"))
salt := digest.Sum(nil)
sessionKey, err := ocrypto.CalculateHKDF(salt, ecdhKey)
if err != nil {
return nil, fmt.Errorf("ocrypto.CalculateHKDF failed: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion sdk/tdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sdk
import (
"bytes"
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
Expand Down Expand Up @@ -579,7 +580,10 @@ func generateWrapKeyWithEC(mode ocrypto.ECCMode, kasPublicKey string, symKey []b
return ecKeyWrappedKeyInfo{}, fmt.Errorf("ocrypto.ComputeECDHKey failed:%w", err)
}

sessionKey, err := ocrypto.CalculateHKDF([]byte("salt"), ecdhKey)
digest := sha256.New()
digest.Write([]byte("TDF"))
salt := digest.Sum(nil)
sessionKey, err := ocrypto.CalculateHKDF(salt, ecdhKey)
if err != nil {
return ecKeyWrappedKeyInfo{}, fmt.Errorf("ocrypto.CalculateHKDF failed:%w", err)
}
Expand Down
Loading