1 /*
2 * GordianKnot: Security Suite
3 * Copyright 2012-2026. Tony Washer
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17 package io.github.tonywasher.joceanus.gordianknot.api.base;
18
19 /**
20 * Explicit lengths for digests.
21 */
22 public enum GordianLength {
23 /**
24 * 32 bits.
25 */
26 LEN_32(32),
27
28 /**
29 * 64 bits.
30 */
31 LEN_64(64),
32
33 /**
34 * 96 bits.
35 */
36 LEN_96(96),
37
38 /**
39 * 128 bits.
40 */
41 LEN_128(128),
42
43 /**
44 * 160 bits.
45 */
46 LEN_160(160),
47
48 /**
49 * 192 bits.
50 */
51 LEN_192(192),
52
53 /**
54 * 200 bits.
55 */
56 LEN_200(200),
57
58 /**
59 * 224 bits.
60 */
61 LEN_224(224),
62
63 /**
64 * 256 bits.
65 */
66 LEN_256(256),
67
68 /**
69 * 283 bits.
70 */
71 LEN_283(283),
72
73 /**
74 * 306 bits.
75 */
76 LEN_306(306),
77
78 /**
79 * 320 bits.
80 */
81 LEN_320(320),
82
83 /**
84 * 366 bits.
85 */
86 LEN_366(366),
87
88 /**
89 * 384 bits.
90 */
91 LEN_384(384),
92
93 /**
94 * 409 bits.
95 */
96 LEN_409(409),
97
98 /**
99 * 431 bits.
100 */
101 LEN_431(431),
102
103 /**
104 * 512 bits.
105 */
106 LEN_512(512),
107
108 /**
109 * 521 bits.
110 */
111 LEN_521(521),
112
113 /**
114 * 571 bits.
115 */
116 LEN_571(571),
117
118 /**
119 * 1024 bits.
120 */
121 LEN_1024(1024),
122
123 /**
124 * 1536 bits.
125 */
126 LEN_1536(1536),
127
128 /**
129 * 2048 bits.
130 */
131 LEN_2048(2048),
132
133 /**
134 * 3072 bits.
135 */
136 LEN_3072(3072),
137
138 /**
139 * 4096 bits.
140 */
141 LEN_4096(4096),
142
143 /**
144 * 6144 bits.
145 */
146 LEN_6144(6144),
147
148 /**
149 * 8192 bits.
150 */
151 LEN_8192(8192);
152
153 /**
154 * The length.
155 */
156 private final int theLength;
157
158 /**
159 * Constructor.
160 *
161 * @param pLength the digest length.
162 */
163 GordianLength(final int pLength) {
164 theLength = pLength;
165 }
166
167 /**
168 * Obtain the length (in bits).
169 *
170 * @return the length
171 */
172 public int getLength() {
173 return theLength;
174 }
175
176 /**
177 * Obtain the length (in bytes).
178 *
179 * @return the length
180 */
181 public int getByteLength() {
182 return theLength / Byte.SIZE;
183 }
184
185 @Override
186 public String toString() {
187 return Integer.toString(theLength);
188 }
189 }