1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.server.kerberos.shared.crypto.checksum; 21 22 23 /** 24 * A type-safe enumeration of Kerberos checksum types. 25 * 26 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 27 * @version $Rev: 588239 $, $Date: 2007-10-25 16:24:28 +0200 (Do, 25 Okt 2007) $ 28 */ 29 public enum ChecksumType implements Comparable<ChecksumType> 30 { 31 /** 32 * The "unknown" checksum type. 33 */ 34 UNKNOWN( -1 ), 35 36 /** 37 * The "null" checksum type. 38 */ 39 NULL( 0 ), 40 41 /** 42 * The CRC32 checksum type. 43 */ 44 CRC32( 1 ), 45 46 /** 47 * The rsa-md4 checksum type. 48 */ 49 RSA_MD4( 2 ), 50 51 /** 52 * The rsa-md4-des checksum type. 53 */ 54 RSA_MD4_DES( 3 ), 55 56 /** 57 * The des-mac checksum type. 58 */ 59 DES_MAC( 4 ), 60 61 /** 62 * The des-mac-k checksum type. 63 */ 64 DES_MAC_K( 5 ), 65 66 /** 67 * The rsa-md4-des-k checksum type. 68 */ 69 RSA_MD4_DES_K( 6 ), 70 71 /** 72 * The rsa-md5 checksum type. 73 */ 74 RSA_MD5( 7 ), 75 76 /** 77 * The rsa-md5-des checksum type. 78 */ 79 RSA_MD5_DES( 8 ), 80 81 /** 82 * The rsa-md5-des3 checksum type. 83 */ 84 RSA_MD5_DES3( 9 ), 85 86 /** 87 * The sha1 (unkeyed) checksum type. 88 */ 89 SHA1( 10 ), 90 91 /** 92 * The hmac-sha1-des3-kd checksum type. 93 */ 94 HMAC_SHA1_DES3_KD( 12 ), 95 96 /** 97 * The hmac-sha1-des3 checksum type. 98 */ 99 HMAC_SHA1_DES3( 13 ), 100 101 /** 102 * The sha1 (unkeyed) checksum type. 103 */ 104 SHA1_2 ( 14 ), 105 106 /** 107 * The hmac-sha1-96-aes128 checksum type. 108 */ 109 HMAC_SHA1_96_AES128( 15 ), 110 111 /** 112 * The hmac-sha1-96-aes256 checksum type. 113 */ 114 HMAC_SHA1_96_AES256( 16 ), 115 116 /** 117 * The hmac-md5 checksum type. 118 */ 119 HMAC_MD5( -138 ); 120 121 122 /** 123 * The value/code for the checksum type. 124 */ 125 private final int ordinal; 126 127 128 /** 129 * Private constructor prevents construction outside of this class. 130 */ 131 private ChecksumType( int ordinal ) 132 { 133 this.ordinal = ordinal; 134 } 135 136 137 /** 138 * Returns the checksum type when specified by its ordinal. 139 * 140 * @param type 141 * @return The checksum type. 142 */ 143 public static ChecksumType getTypeByOrdinal( int type ) 144 { 145 switch ( type ) 146 { 147 case -1 : return UNKNOWN; 148 case 0 : return NULL; 149 case 1 : return CRC32; 150 case 2 : return RSA_MD4; 151 case 3 : return RSA_MD4_DES; 152 case 4 : return DES_MAC; 153 case 5 : return DES_MAC_K; 154 case 6 : return RSA_MD4_DES_K; 155 case 7 : return RSA_MD5; 156 case 8 : return RSA_MD5_DES; 157 case 9 : return RSA_MD5_DES3; 158 case 10 : return SHA1; 159 case 12 : return HMAC_SHA1_DES3_KD; 160 case 13 : return HMAC_SHA1_DES3; 161 case 14 : return SHA1_2; 162 case 15 : return HMAC_SHA1_96_AES128; 163 case 16 : return HMAC_SHA1_96_AES256; 164 case -138 : return HMAC_MD5; 165 default : return UNKNOWN; 166 } 167 } 168 169 170 /** 171 * Returns the number associated with this checksum type. 172 * 173 * @return The checksum type ordinal. 174 */ 175 public int getOrdinal() 176 { 177 return ordinal; 178 } 179 }