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 * 320 bits.
70 */
71 LEN_320(320),
72
73 /**
74 * 384 bits.
75 */
76 LEN_384(384),
77
78 /**
79 * 512 bits.
80 */
81 LEN_512(512),
82
83 /**
84 * 1024 bits.
85 */
86 LEN_1024(1024);
87
88 /**
89 * The length.
90 */
91 private final int theLength;
92
93 /**
94 * Constructor.
95 *
96 * @param pLength the digest length.
97 */
98 GordianLength(final int pLength) {
99 theLength = pLength;
100 }
101
102 /**
103 * Obtain the length (in bits).
104 *
105 * @return the length
106 */
107 public int getLength() {
108 return theLength;
109 }
110
111 /**
112 * Obtain the length (in bytes).
113 *
114 * @return the length
115 */
116 public int getByteLength() {
117 return theLength / Byte.SIZE;
118 }
119
120 @Override
121 public String toString() {
122 return Integer.toString(theLength);
123 }
124 }