01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package javacard.security;
28:
29: import javacard.framework.CardRuntimeException;
30:
31: /**
32: * <code>CryptoException</code> represents a cryptography-related exception.
33: */
34:
35: public class CryptoException extends CardRuntimeException {
36:
37: // CryptoException reason codes
38: /**
39: * This reason code is used to indicate that one or more input parameters
40: * is out of allowed bounds.
41: */
42: public static final short ILLEGAL_VALUE = 1;
43:
44: /**
45: * This reason code is used to indicate that the key is uninitialized.
46: */
47: public static final short UNINITIALIZED_KEY = 2;
48:
49: /**
50: * This reason code is used to indicate that the requested
51: * algorithm or key type
52: * is not supported.
53: */
54: public static final short NO_SUCH_ALGORITHM = 3;
55:
56: /**
57: * This reason code is used to indicate that the signature or
58: * cipher object has not been
59: * correctly initialized for the requested operation.
60: */
61: public static final short INVALID_INIT = 4;
62:
63: /**
64: * This reason code is used to indicate that the signature or
65: * cipher algorithm does
66: * not pad the incoming message and the input message is not block aligned.
67: */
68: public static final short ILLEGAL_USE = 5;
69:
70: /**
71: * Constructs a <code>CryptoException</code> with the specified reason.
72: * To conserve on resources use <code>throwIt()</code>
73: * to use the JCRE-owned instance of this class.
74: * @param reason the reason for the exception
75: */
76: public CryptoException(short reason) {
77: super (reason);
78: }
79:
80: /**
81: * Throws an instance of <code>CryptoException</code> with the
82: * specified reason.
83: * @param reason the reason for the exception
84: * @exception CryptoException always
85: */
86: public static void throwIt(short reason) {
87: throw new CryptoException(reason);
88: }
89: }
|