Skip to content
Draft
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
18 changes: 15 additions & 3 deletions docs/grpc/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/authorization/authorization.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/authorization/v2/authorization.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/openapi/kas/kas.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/policy/actions/actions.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/policy/attributes/attributes.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/policy/namespaces/namespaces.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/policy/objects.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/policy/obligations/obligations.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/openapi/policy/unsafe/unsafe.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/ocrypto/asym_decryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func FromPrivatePEMWithSalt(privateKeyInPem string, salt, info []byte) (PrivateK
if block == nil {
return AsymDecryption{}, errors.New("failed to parse PEM formatted private key")
}
if block.Type == PEMBlockXWingPrivateKey {
return NewSaltedXWingDecryptor(block.Bytes, salt, info)
}
if params, ok := hybridParamsFromPrivatePEMType(block.Type); ok {
return newSaltedHybridECMLKEMDecryptor(params, block.Bytes, salt, info)
}
Comment on lines +46 to +51
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is a type mismatch here. NewSaltedXWingDecryptor and newSaltedHybridECMLKEMDecryptor return pointers to specific decryptor types (e.g., *XWingDecryptor), but FromPrivatePEMWithSalt is declared to return an AsymDecryption struct. This will cause a compilation error. You likely need to wrap these decryptors in an AsymDecryption instance before returning.


priv, err := x509.ParsePKCS8PrivateKey(block.Bytes)
switch {
Expand Down
16 changes: 14 additions & 2 deletions lib/ocrypto/asym_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (
type SchemeType string

const (
RSA SchemeType = "wrapped"
EC SchemeType = "ec-wrapped"
RSA SchemeType = "wrapped"
EC SchemeType = "ec-wrapped"
Hybrid SchemeType = "hybrid-wrapped"
)

type PublicKeyEncryptor interface {
Expand Down Expand Up @@ -69,6 +70,17 @@ func FromPublicPEM(publicKeyInPem string) (PublicKeyEncryptor, error) {
}

func FromPublicPEMWithSalt(publicKeyInPem string, salt, info []byte) (PublicKeyEncryptor, error) {
block, _ := pem.Decode([]byte(publicKeyInPem))
if block == nil {
return nil, errors.New("failed to parse PEM formatted public key")
}
if block.Type == PEMBlockXWingPublicKey {
return NewXWingEncryptor(block.Bytes, salt, info)
}
if params, ok := hybridParamsFromPublicPEMType(block.Type); ok {
return newHybridECMLKEMEncryptor(params, block.Bytes, salt, info)
}

pub, err := getPublicPart(publicKeyInPem)
if err != nil {
return nil, err
Expand Down
28 changes: 23 additions & 5 deletions lib/ocrypto/ec_key_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ type ECCMode uint8
type KeyType string

const (
RSA2048Key KeyType = "rsa:2048"
RSA4096Key KeyType = "rsa:4096"
EC256Key KeyType = "ec:secp256r1"
EC384Key KeyType = "ec:secp384r1"
EC521Key KeyType = "ec:secp521r1"
RSA2048Key KeyType = "rsa:2048"
RSA4096Key KeyType = "rsa:4096"
EC256Key KeyType = "ec:secp256r1"
EC384Key KeyType = "ec:secp384r1"
EC521Key KeyType = "ec:secp521r1"
HybridXWingKey KeyType = "hpqt:xwing"
HybridSecp256r1MLKEM768Key KeyType = "hpqt:secp256r1-mlkem768"
HybridSecp384r1MLKEM1024Key KeyType = "hpqt:secp384r1-mlkem1024"
)

const (
Expand Down Expand Up @@ -64,6 +67,12 @@ func NewKeyPair(kt KeyType) (KeyPair, error) {
return nil, err
}
return NewECKeyPair(mode)
case HybridXWingKey:
return NewXWingKeyPair()
case HybridSecp256r1MLKEM768Key:
return NewP256MLKEM768KeyPair()
case HybridSecp384r1MLKEM1024Key:
return NewP384MLKEM1024KeyPair()
default:
return nil, fmt.Errorf("unsupported key type: %v", kt)
}
Expand Down Expand Up @@ -91,6 +100,15 @@ func IsRSAKeyType(kt KeyType) bool {
}
}

func IsHybridKeyType(kt KeyType) bool {
switch kt { //nolint:exhaustive // only handle hybrid types
case HybridXWingKey, HybridSecp256r1MLKEM768Key, HybridSecp384r1MLKEM1024Key:
return true
default:
return false
}
}

// GetECCurveFromECCMode return elliptic curve from ecc mode
func GetECCurveFromECCMode(mode ECCMode) (elliptic.Curve, error) {
var c elliptic.Curve
Expand Down
Loading
Loading