OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [javax/] [crypto/] [MacSpi.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* MacSpi.java -- The MAC service provider interface.
2
   Copyright (C) 2004  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath 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 for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package javax.crypto;
40
 
41
import java.security.InvalidAlgorithmParameterException;
42
import java.security.InvalidKeyException;
43
import java.security.Key;
44
import java.security.spec.AlgorithmParameterSpec;
45
 
46
/**
47
 * This is the <i>Service Provider Interface</i> (<b>SPI</b>) for the
48
 * {@link Mac} class.
49
 *
50
 * <p>Providers wishing to implement a Mac must subclass this class and
51
 * provide appropriate implementations of all its abstract methods,
52
 * then provide an entry pointing to this implementation in the master
53
 * {@link java.security.Provider} class.
54
 *
55
 * <p>Implementations may optionally implement the {@link
56
 * java.lang.Cloneable} interface.
57
 *
58
 * @author Casey Marshall (csm@gnu.org)
59
 * @since 1.4
60
 */
61
public abstract class MacSpi
62
{
63
 
64
  // Constructor.
65
  // ------------------------------------------------------------------------
66
 
67
  /**
68
   * Create a new MacSpi instance.
69
   */
70
  public MacSpi()
71
  {
72
  }
73
 
74
  // Instance methods.
75
  // ------------------------------------------------------------------------
76
 
77
  /**
78
   * Returns a clone of this instance if cloning is supported.
79
   *
80
   * @return A clone of this instance.
81
   * @throws java.lang.CloneNotSupportedException If this instance does
82
   *         not support cloneing.
83
   */
84
  public Object clone() throws CloneNotSupportedException
85
  {
86
    return super.clone();
87
  }
88
 
89
  // Abstract instance methods.
90
  // ------------------------------------------------------------------------
91
 
92
  /**
93
   * Finalize the computation of this MAC and return the result as a
94
   * byte array.
95
   *
96
   * @return The MAC.
97
   */
98
  protected abstract byte[] engineDoFinal();
99
 
100
  /**
101
   * Return the total length, in bytes, of the computed MAC (the length
102
   * of the byte array returned by {@link #doFinal()}.
103
   *
104
   * @return The MAC length.
105
   */
106
  protected abstract int engineGetMacLength();
107
 
108
  /**
109
   * Initialize (or re-initialize) this instance.
110
   *
111
   * @param key    The key to use.
112
   * @param params The parameters to use.
113
   * @throws java.security.InvalidAlgorithmParameterException If this
114
   *         instance rejects the specified parameters.
115
   * @throws java.security.InvalidKeyException If this instance rejects
116
   *         the specified key.
117
   */
118
  protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
119
    throws InvalidAlgorithmParameterException, InvalidKeyException;
120
 
121
  /**
122
   * Reset this instance. After this method succeeds, the state of this
123
   * instance should be the same as it was before any data was input
124
   * (possibly after a call to {@link
125
   * #init(java.security.Key,java.security.spec.AlgorithmParameterSpec)},
126
   * possibly not).
127
   */
128
  protected abstract void engineReset();
129
 
130
  /**
131
   * Update this MAC with a single byte.
132
   *
133
   * @param input The next byte.
134
   */
135
  protected abstract void engineUpdate(byte input);
136
 
137
  /**
138
   * Update this MAC with a portion of a byte array.
139
   *
140
   * @param input  The next bytes.
141
   * @param offset The index in <code>input</code> at which to start.
142
   * @param length The number of bytes to update.
143
   */
144
  protected abstract void engineUpdate(byte[] input, int offset, int length);
145
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.