MCPcopy
hub / github.com/zitadel/zitadel / checkEncryptionAlgorithm

Function checkEncryptionAlgorithm

internal/crypto/crypto.go:114–128  ·  view source on GitHub ↗
(value *CryptoValue, alg EncryptionAlgorithm)

Source from the content-addressed store, hash-verified

112}
113
114func checkEncryptionAlgorithm(value *CryptoValue, alg EncryptionAlgorithm) error {
115 if value == nil {
116 return zerrors.ThrowInvalidArgument(nil, "CRYPT-mNsQwe", "input value cannot be nil")
117 }
118 if alg == nil {
119 return zerrors.ThrowInvalidArgument(nil, "CRYPT-paiRey", "input encryption algorithm cannot be nil")
120 }
121 if value.Algorithm != alg.Algorithm() {
122 return zerrors.ThrowInvalidArgument(nil, "CRYPT-Nx7XlT", "value was encrypted with a different key")
123 }
124 if slices.Contains(alg.DecryptionKeyIDs(), value.KeyID) {
125 return nil
126 }
127 return zerrors.ThrowInvalidArgument(nil, "CRYPT-Kq12vn", "value was encrypted with a different key")
128}
129
130func CheckToken(alg EncryptionAlgorithm, token string, content string) error {
131 if token == "" {

Callers 2

DecryptFunction · 0.85
DecryptStringFunction · 0.85

Calls 3

ThrowInvalidArgumentFunction · 0.92
AlgorithmMethod · 0.65
DecryptionKeyIDsMethod · 0.65

Tested by

no test coverage detected