001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 package org.apache.directory.server.kerberos.shared.crypto.checksum; 021 022 023 /** 024 * A type-safe enumeration of Kerberos checksum types. 025 * 026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 027 * @version $Rev: 588239 $, $Date: 2007-10-25 16:24:28 +0200 (Thu, 25 Oct 2007) $ 028 */ 029 public enum ChecksumType implements Comparable<ChecksumType> 030 { 031 /** 032 * The "unknown" checksum type. 033 */ 034 UNKNOWN( -1 ), 035 036 /** 037 * The "null" checksum type. 038 */ 039 NULL( 0 ), 040 041 /** 042 * The CRC32 checksum type. 043 */ 044 CRC32( 1 ), 045 046 /** 047 * The rsa-md4 checksum type. 048 */ 049 RSA_MD4( 2 ), 050 051 /** 052 * The rsa-md4-des checksum type. 053 */ 054 RSA_MD4_DES( 3 ), 055 056 /** 057 * The des-mac checksum type. 058 */ 059 DES_MAC( 4 ), 060 061 /** 062 * The des-mac-k checksum type. 063 */ 064 DES_MAC_K( 5 ), 065 066 /** 067 * The rsa-md4-des-k checksum type. 068 */ 069 RSA_MD4_DES_K( 6 ), 070 071 /** 072 * The rsa-md5 checksum type. 073 */ 074 RSA_MD5( 7 ), 075 076 /** 077 * The rsa-md5-des checksum type. 078 */ 079 RSA_MD5_DES( 8 ), 080 081 /** 082 * The rsa-md5-des3 checksum type. 083 */ 084 RSA_MD5_DES3( 9 ), 085 086 /** 087 * The sha1 (unkeyed) checksum type. 088 */ 089 SHA1( 10 ), 090 091 /** 092 * The hmac-sha1-des3-kd checksum type. 093 */ 094 HMAC_SHA1_DES3_KD( 12 ), 095 096 /** 097 * The hmac-sha1-des3 checksum type. 098 */ 099 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 }