1 7 8 9 package org.enhydra.oyster.crypto; 10 11 import org.enhydra.oyster.exception.SMIMEException; 12 13 14 21 public class AlgorithmChecker { 22 23 26 private static int keySizeInBits = 0; 27 28 31 private String algorithmName = null; 32 33 43 public AlgorithmChecker (String algorithm0, int keySize0) throws SMIMEException 44 { 45 if (!algorithm0.equalsIgnoreCase("DES") && 46 !algorithm0.equalsIgnoreCase("RC2_CBC") && 47 !algorithm0.equals("DES_EDE3_CBC")) { 48 throw new SMIMEException(this, 1013); 49 } 50 if (algorithm0.equalsIgnoreCase("RC2_CBC")) { 51 algorithmName = "RC2"; 52 if (keySize0 != 40 && keySize0 != 64 && keySize0 != 128) 53 throw new SMIMEException(this, 1014); 54 keySizeInBits = keySize0; 55 } 56 else if (algorithm0.equalsIgnoreCase("DES_EDE3_CBC")) { 57 algorithmName = "DESede"; 58 if (keySize0 != 128 && keySize0 != 192) 59 throw new SMIMEException(this, 1015); 60 keySizeInBits = keySize0; 61 } 62 else { 63 algorithmName = "DES"; 64 if (keySize0 != 56) 65 throw new SMIMEException(this, 1016); 66 keySizeInBits = keySize0; 67 } 68 } 69 70 74 public String getAlgorithmName () { 75 return algorithmName; 76 } 77 78 82 public int getKeySize () { 83 return keySizeInBits; 84 } 85 } 86 87 88 89 | Popular Tags |