1use thiserror::Error;
2
3#[derive(Error, Debug, PartialEq)]
4pub enum QuantCryptError {
6 #[error("Cannot read from the specified file")]
7 FileReadError,
8 #[error("Content cannot be empty")]
9 EmptyContent,
10 #[error("Cannot write to the specified file")]
11 FileWriteError,
12 #[error("Invalid RecipientInfo")]
13 InvalidRecipientInfo,
14 #[error("Certificate doesn't contain a Subject Key Identifier extension")]
15 SkidNotFound,
16 #[error("The path doesn't exist or is not a directory")]
17 InvalidDirectoryPath,
18 #[error("Invalid Nonce")]
19 InvalidAesNonce,
20 #[error("Invalid attribute")]
21 InvalidAttribute,
22 #[error("Key wrap failed")]
23 KeyWrapFailed,
24 #[error("Key unwrap failed")]
25 KeyUnwrapFailed,
26 #[error("Invalid OID")]
27 InvalidOid,
28 #[error("Invalid public key")]
29 InvalidPublicKey,
30 #[error("Invalid private key")]
31 InvalidPrivateKey,
32 #[error("Serilization to/from PEM/DER failed")]
33 SerializationFailed,
34 #[error("Signature verification failed")]
35 SignatureVerificationFailed,
36 #[error("Signature failed")]
37 SignatureFailed,
38 #[error("Invalid signature")]
39 InvalidSignature,
40 #[error("Key pair generation failed")]
41 KeyPairGenerationFailed,
42 #[error("Missing not_after")]
43 MissingNotAfter,
44 #[error("Missing subject")]
45 MissingSubject,
46 #[error("Missing public key")]
47 MissingPublicKey,
48 #[error("Bad private key")]
49 BadPrivateKey,
50 #[error("Bad public key")]
51 BadPublicKey,
52 #[error("Bad subject")]
53 BadSubject,
54 #[error("Invalid HKDF length")]
55 InvalidHkdfLength,
56 #[error("Bad issuers public key")]
57 BadIssuersPublicKey,
58 #[error("Bad serial number key")]
59 BadSerialNumber,
60 #[error("Bad extension")]
61 BadExtension,
62 #[error("Invalid not_before. Please use an ISO 8601 date string and ensure that not_before is before not_after")]
63 InvalidNotBefore,
64 #[error("Invalid not after. Please use an ISO 8601 date string and ensure that not_after is after not_before. Also, ensure that not_after is not in the past")]
65 InvalidNotAfter,
66 #[error("Certificate is invalid")]
67 InvalidCertificate,
68 #[error("Invalid enveloped data")]
69 InvalidEnvelopedData,
70 #[error(
71 "Unsupported operation. Only DSA keys can be used for signing and KEM keys for encap/decap"
72 )]
73 UnsupportedOperation,
74 #[error("Not implemented")]
75 NotImplemented,
76 #[error("Invalid ciphertext")]
77 InvalidCiphertext,
78 #[error("Encap failed")]
79 EncapFailed,
80 #[error("Decap failed")]
81 DecapFailed,
82 #[error("Unknown error")]
83 Unknown,
84 #[error("Invalid content")]
85 InvalidContent,
86 #[error("Unsupported Content Encryption Algorithm")]
87 UnsupportedContentEncryptionAlgorithm,
88}