aboutsummaryrefslogtreecommitdiff
path: root/central/src/main/java/com/wireguard/crypto/KeyFormatException.java
diff options
context:
space:
mode:
Diffstat (limited to 'central/src/main/java/com/wireguard/crypto/KeyFormatException.java')
-rw-r--r--central/src/main/java/com/wireguard/crypto/KeyFormatException.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/central/src/main/java/com/wireguard/crypto/KeyFormatException.java b/central/src/main/java/com/wireguard/crypto/KeyFormatException.java
new file mode 100644
index 0000000..21eb592
--- /dev/null
+++ b/central/src/main/java/com/wireguard/crypto/KeyFormatException.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * https://raw.githubusercontent.com/WireGuard/wireguard-android/5b5ba88a97b5310c532b42b526f78d1c747965f8/tunnel/src/main/java/com/wireguard/crypto/KeyFormatException.java
+ */
+
+package com.wireguard.crypto;
+
+import com.wireguard.util.NonNullForAll;
+
+/**
+ * An exception thrown when attempting to parse an invalid key (too short, too long, or byte
+ * data inappropriate for the format). The format being parsed can be accessed with the
+ * {@link #getFormat} method.
+ */
+@NonNullForAll
+public final class KeyFormatException extends Exception {
+ private final Key.Format format;
+ private final Type type;
+
+ KeyFormatException(final Key.Format format, final Type type) {
+ this.format = format;
+ this.type = type;
+ }
+
+ public Key.Format getFormat() {
+ return format;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public enum Type {
+ CONTENTS,
+ LENGTH
+ }
+} \ No newline at end of file