~ubuntu-branches/ubuntu/precise/classpath/precise

« back to all changes in this revision

Viewing changes to javax/crypto/CipherSpi.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2006-05-27 16:11:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060527161115-h6e39eposdt5snb6
Tags: 2:0.91-3
* Install header files to /usr/include/classpath.
* debian/control: classpath: Conflict with jamvm < 1.4.3 and
  cacao < 0.96 (Closes: #368172).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* CipherSpi.java -- The cipher service provider interface.
2
 
   Copyright (C) 2004  Free Software Foundation, Inc.
 
2
   Copyright (C) 2004, 2006  Free Software Foundation, Inc.
3
3
 
4
4
This file is part of GNU Classpath.
5
5
 
38
38
 
39
39
package javax.crypto;
40
40
 
 
41
import java.nio.ByteBuffer;
 
42
 
41
43
import java.security.AlgorithmParameters;
42
44
import java.security.InvalidAlgorithmParameterException;
43
45
import java.security.InvalidKeyException;
179
181
  throws IllegalBlockSizeException, BadPaddingException, ShortBufferException;
180
182
 
181
183
  /**
 
184
   * @since 1.5
 
185
   */
 
186
  protected int engineDoFinal (ByteBuffer input, ByteBuffer output)
 
187
    throws BadPaddingException, IllegalBlockSizeException,
 
188
           ShortBufferException
 
189
  {
 
190
    int total = 0;
 
191
    byte[] inbuf = new byte[256];
 
192
    while (input.hasRemaining ())
 
193
      {
 
194
        int in = Math.min (inbuf.length, input.remaining ());
 
195
        input.get (inbuf, 0, in);
 
196
        byte[] outbuf = new byte[engineGetOutputSize (in)];
 
197
        int out = 0;
 
198
        if (input.hasRemaining ()) // i.e., we have more 'update' calls
 
199
          out = engineUpdate (inbuf, 0, in, outbuf, 0);
 
200
        else
 
201
          out = engineDoFinal (inbuf, 0, in, outbuf, 0);
 
202
        output.put (outbuf, 0, out);
 
203
        total += out;
 
204
      }
 
205
    return total;
 
206
  }
 
207
 
 
208
  /**
182
209
   * Returns the block size of the underlying cipher.
183
210
   *
184
211
   * @return The block size.
380
407
  throws ShortBufferException;
381
408
 
382
409
  /**
 
410
   * @since 1.5
 
411
   */
 
412
  protected int engineUpdate (ByteBuffer input, ByteBuffer output)
 
413
    throws ShortBufferException
 
414
  {
 
415
    int total = 0;
 
416
    byte[] inbuf = new byte[256];
 
417
    while (input.hasRemaining ())
 
418
      {
 
419
        int in = Math.min (inbuf.length, input.remaining ());
 
420
        input.get (inbuf, 0, in);
 
421
        byte[] outbuf = new byte[engineGetOutputSize (in)];
 
422
        int out = engineUpdate (inbuf, 0, in, outbuf, 0);
 
423
        output.put (outbuf, 0, out);
 
424
        total += out;
 
425
      }
 
426
    return total;
 
427
  }
 
428
 
 
429
  /**
383
430
   * <p>Wrap a key.</p>
384
431
   *
385
432
   * <p>For compatibility this method is not declared