Skip to content

Instantly share code, notes, and snippets.

@msfjarvis
Created January 17, 2024 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msfjarvis/64dc655b1a2f75a063f803b7106acbf7 to your computer and use it in GitHub Desktop.
Save msfjarvis/64dc655b1a2f75a063f803b7106acbf7 to your computer and use it in GitHub Desktop.
diff --git a/src/kotlin/kage/errors/Bech32Exception.kt b/src/kotlin/kage/errors/Bech32Exception.kt
index 63ca56903cd2..47d0d22f1e06 100644
--- a/src/kotlin/kage/errors/Bech32Exception.kt
+++ b/src/kotlin/kage/errors/Bech32Exception.kt
@@ -6,7 +6,5 @@
package kage.errors
/** Thrown when encoding or decoding Bech32 */
-public class Bech32Exception(
- message: String? = null,
- cause: Throwable? = null,
-) : Exception(message, cause)
+public class Bech32Exception(message: String? = null, cause: Throwable? = null) :
+ Exception(message, cause)
diff --git a/src/kotlin/kage/errors/CryptoException.kt b/src/kotlin/kage/errors/CryptoException.kt
index e38aa930df33..0a2e6f030127 100644
--- a/src/kotlin/kage/errors/CryptoException.kt
+++ b/src/kotlin/kage/errors/CryptoException.kt
@@ -6,63 +6,46 @@
package kage.errors
/** Wrapper class for errors raised during a cryptographic operation. */
-public sealed class CryptoException(
- message: String? = null,
- cause: Throwable? = null,
-) : Exception(message, cause)
+public sealed class CryptoException(message: String? = null, cause: Throwable? = null) :
+ Exception(message, cause)
/** Raised when no [kage.Recipient] is available in the ciphertext. */
-public class NoRecipientsException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class NoRecipientsException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/**
* Raised when there are more than one [kage.Recipient]s and one is an
* [kage.crypto.scrypt.ScryptRecipient]. This is a specially cased situation from the spec which
* requires that there only be one [kage.Recipient] if it is a [kage.crypto.scrypt.ScryptRecipient].
*/
-public class InvalidScryptRecipientException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class InvalidScryptRecipientException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/** Raised when an incompatible stanza is provided to [kage.Identity.unwrap] */
-public sealed class InvalidIdentityException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public sealed class InvalidIdentityException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/** Raised when an error occurs when unwrapping an scrypt stanza from an [kage.Identity]. */
-public class ScryptIdentityException(
- message: String? = null,
- cause: Throwable? = null,
-) : InvalidIdentityException(message, cause)
+public class ScryptIdentityException(message: String? = null, cause: Throwable? = null) :
+ InvalidIdentityException(message, cause)
/** Raised when an error occurs when unwrapping a X25519 stanza from an [kage.Identity]. */
-public class X25519IdentityException(
- message: String? = null,
- cause: Throwable? = null,
-) : InvalidIdentityException(message, cause)
+public class X25519IdentityException(message: String? = null, cause: Throwable? = null) :
+ InvalidIdentityException(message, cause)
/**
* Raised when an error occurs while calculating the X25519 shared secret. If the X25519 share is a
* low order point, the shared secret is the disallowed all-zero value.
*/
-public class X25519LowOrderPointException(
- message: String? = null,
- cause: Throwable? = null,
-) : InvalidIdentityException(message, cause)
+public class X25519LowOrderPointException(message: String? = null, cause: Throwable? = null) :
+ InvalidIdentityException(message, cause)
/** Raised when there are no [kage.Identity]s when decrypting a ciphertext */
-public class NoIdentitiesException(
- message: String? = null,
- cause: Throwable? = null,
-) : InvalidIdentityException(message, cause)
+public class NoIdentitiesException(message: String? = null, cause: Throwable? = null) :
+ InvalidIdentityException(message, cause)
-public class IncorrectCipherTextSizeException(
- cause: Throwable? = null,
-) : CryptoException("Incorrect cipher text size", cause)
+public class IncorrectCipherTextSizeException(cause: Throwable? = null) :
+ CryptoException("Incorrect cipher text size", cause)
/**
* Raised when an identity is not suitable to decrypt a specific recipient block.
@@ -70,36 +53,25 @@ public class IncorrectCipherTextSizeException(
* This is not a fatal exception, kage code should catch this exception and try a different
* identity, or fail if other identity does not exist
*/
-public class IncorrectIdentityException(
- cause: Throwable? = null,
-) : CryptoException("incorrect identity for recipient block", cause)
+public class IncorrectIdentityException(cause: Throwable? = null) :
+ CryptoException("incorrect identity for recipient block", cause)
/** Thrown when an error occurs while streaming encrypted or decrypted data */
-public class StreamException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class StreamException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/** Raised when the Base64 string is not canonical according to RFC 4648 section 3.5 */
-public class InvalidBase64StringException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class InvalidBase64StringException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/** Raised when the mac is incorrect */
-public class IncorrectHMACException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class IncorrectHMACException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/** Raised when the mac is invalid (truncated or the wrong size) */
-public class InvalidHMACHeaderException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class InvalidHMACHeaderException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
/** Thrown when an error occurs while encoding/decoding armor data */
-public class ArmorCodingException(
- message: String? = null,
- cause: Throwable? = null,
-) : CryptoException(message, cause)
+public class ArmorCodingException(message: String? = null, cause: Throwable? = null) :
+ CryptoException(message, cause)
diff --git a/src/kotlin/kage/errors/ParseException.kt b/src/kotlin/kage/errors/ParseException.kt
index a7067a110922..45713754a53b 100644
--- a/src/kotlin/kage/errors/ParseException.kt
+++ b/src/kotlin/kage/errors/ParseException.kt
@@ -6,46 +6,32 @@
package kage.errors
/** Wrapper type for errors triggered while parsing an [kage.format.AgeStanza] */
-public sealed class ParseException(
- message: String? = null,
- cause: Throwable? = null,
-) : Exception(message, cause)
+public sealed class ParseException(message: String? = null, cause: Throwable? = null) :
+ Exception(message, cause)
/** Raised when a non-ASCII string is encountered when parsing an [kage.format.AgeHeader]. */
-public class InvalidArbitraryStringException(
- message: String? = null,
- cause: Throwable? = null,
-) : ParseException(message, cause)
+public class InvalidArbitraryStringException(message: String? = null, cause: Throwable? = null) :
+ ParseException(message, cause)
/** Raised when the parsed version is not an expected one. */
-public class InvalidVersionException(
- message: String? = null,
- cause: Throwable? = null,
-) : ParseException(message, cause)
+public class InvalidVersionException(message: String? = null, cause: Throwable? = null) :
+ ParseException(message, cause)
/** Raised when a failure occurs while parsing [kage.format.AgeStanza] for [kage.Recipient]s. */
-public class InvalidRecipientException(
- message: String? = null,
- cause: Throwable? = null,
-) : ParseException(message, cause)
+public class InvalidRecipientException(message: String? = null, cause: Throwable? = null) :
+ ParseException(message, cause)
/** Raised when the footer for a [kage.format.AgeHeader] is incorrect. */
-public class InvalidFooterException(
- message: String? = null,
- cause: Throwable? = null,
-) : ParseException(message, cause)
+public class InvalidFooterException(message: String? = null, cause: Throwable? = null) :
+ ParseException(message, cause)
/** Raised when the [kage.format.AgeHeader.mac] is empty when writing a [kage.format.AgeHeader]. */
-public class InvalidHMACException(
- message: String? = null,
- cause: Throwable? = null,
-) : ParseException(message, cause)
+public class InvalidHMACException(message: String? = null, cause: Throwable? = null) :
+ ParseException(message, cause)
/**
* Raised when the [kage.format.AgeKeyFile.privateKey] is empty when parsing a
* [kage.format.AgeKeyFile].
*/
-public class InvalidAgeKeyException(
- message: String? = null,
- cause: Throwable? = null,
-) : ParseException(message, cause)
+public class InvalidAgeKeyException(message: String? = null, cause: Throwable? = null) :
+ ParseException(message, cause)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment