storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/crypto/error.go (about) 1 // MinIO Cloud Storage, (C) 2015, 2016, 2017, 2018 MinIO, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package crypto 16 17 import ( 18 "fmt" 19 ) 20 21 // Error is the generic type for any error happening during decrypting 22 // an object. It indicates that the object itself or its metadata was 23 // modified accidentally or maliciously. 24 type Error struct { 25 err error 26 } 27 28 // Errorf - formats according to a format specifier and returns 29 // the string as a value that satisfies error of type crypto.Error 30 func Errorf(format string, a ...interface{}) error { 31 return Error{err: fmt.Errorf(format, a...)} 32 } 33 34 // Unwrap the internal error. 35 func (e Error) Unwrap() error { return e.err } 36 37 // Error 'error' compatible method. 38 func (e Error) Error() string { 39 if e.err == nil { 40 return "crypto: cause <nil>" 41 } 42 return e.err.Error() 43 } 44 45 var ( 46 // ErrInvalidEncryptionMethod indicates that the specified SSE encryption method 47 // is not supported. 48 ErrInvalidEncryptionMethod = Errorf("The encryption method is not supported") 49 50 // ErrInvalidCustomerAlgorithm indicates that the specified SSE-C algorithm 51 // is not supported. 52 ErrInvalidCustomerAlgorithm = Errorf("The SSE-C algorithm is not supported") 53 54 // ErrMissingCustomerKey indicates that the HTTP headers contains no SSE-C client key. 55 ErrMissingCustomerKey = Errorf("The SSE-C request is missing the customer key") 56 57 // ErrMissingCustomerKeyMD5 indicates that the HTTP headers contains no SSE-C client key 58 // MD5 checksum. 59 ErrMissingCustomerKeyMD5 = Errorf("The SSE-C request is missing the customer key MD5") 60 61 // ErrInvalidCustomerKey indicates that the SSE-C client key is not valid - e.g. not a 62 // base64-encoded string or not 256 bits long. 63 ErrInvalidCustomerKey = Errorf("The SSE-C client key is invalid") 64 65 // ErrSecretKeyMismatch indicates that the provided secret key (SSE-C client key / SSE-S3 KMS key) 66 // does not match the secret key used during encrypting the object. 67 ErrSecretKeyMismatch = Errorf("The secret key does not match the secret key used during upload") 68 69 // ErrCustomerKeyMD5Mismatch indicates that the SSE-C key MD5 does not match the 70 // computed MD5 sum. This means that the client provided either the wrong key for 71 // a certain MD5 checksum or the wrong MD5 for a certain key. 72 ErrCustomerKeyMD5Mismatch = Errorf("The provided SSE-C key MD5 does not match the computed MD5 of the SSE-C key") 73 // ErrIncompatibleEncryptionMethod indicates that both SSE-C headers and SSE-S3 headers were specified, and are incompatible 74 // The client needs to remove the SSE-S3 header or the SSE-C headers 75 ErrIncompatibleEncryptionMethod = Errorf("Server side encryption specified with both SSE-C and SSE-S3 headers") 76 ) 77 78 var ( 79 errMissingInternalIV = Errorf("The object metadata is missing the internal encryption IV") 80 errMissingInternalSealAlgorithm = Errorf("The object metadata is missing the internal seal algorithm") 81 82 errInvalidInternalIV = Errorf("The internal encryption IV is malformed") 83 errInvalidInternalSealAlgorithm = Errorf("The internal seal algorithm is invalid and not supported") 84 ) 85 86 var ( 87 // errOutOfEntropy indicates that the a source of randomness (PRNG) wasn't able 88 // to produce enough random data. This is fatal error and should cause a panic. 89 errOutOfEntropy = Errorf("Unable to read enough randomness from the system") 90 )