(value *CryptoValue, alg EncryptionAlgorithm)
| 112 | } |
| 113 | |
| 114 | func 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 | |
| 130 | func CheckToken(alg EncryptionAlgorithm, token string, content string) error { |
| 131 | if token == "" { |
no test coverage detected