gnu.javax.crypto.sasl.srp

Class CALG


public final class CALG
extends Object

A Factory class that returns CALG (Confidentiality Algorithm) instances that operate as described in the draft-burdis-cat-sasl-srp-08.

The designated CALG block cipher should be used in OFB (Output Feedback Block) mode in the ISO variant, as described in The Handbook of Applied Cryptography, algorithm 7.20.

Let k be the block size of the chosen symmetric key block cipher algorithm; e.g. for AES this is 128 bits or 16 octets. The OFB mode used shall be of length/size k.

It is recommended that block ciphers operating in OFB mode be used with an Initial Vector (the mode's IV). In such a mode of operation - OFB with key re-use - the IV need not be secret. For the mechanism in question the IVs shall be a random octet sequence of k bytes.

The input data to the confidentiality protection algorithm shall be a multiple of the symmetric cipher block size k. When the input length is not a multiple of k octets, the data shall be padded according to the following scheme:

Assuming the length of the input is l octets, (k - (l mod k)) octets, all having the value (k - (l mod k)), shall be appended to the original data. In other words, the input is padded at the trailing end with one of the following sequences:


                     01 -- if l mod k = k-1
                    02 02 -- if l mod k = k-2
                              ...
                              ...
                              ...
                  k k ... k k -- if l mod k = 0
 

The padding can be removed unambiguously since all input is padded and no padding sequence is a suffix of another. This padding method is well-defined if and only if k < 256 octets, which is the case with symmetric key block ciphers today, and in the forseeable future.

Method Summary

byte[]
doFinal(byte[] data)
Encrypts or decrypts, depending on the mode already set, a designated array of bytes and returns the result.
byte[]
doFinal(byte[] data, int offset, int length)
Encrypts or decrypts, depending on the mode already set, a designated array of bytes and returns the result.
void
init(KDF kdf, byte[] iv, Direction dir)
Initialises a SASL-SRP CALG implementation.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

doFinal

public byte[] doFinal(byte[] data)
            throws ConfidentialityException
Encrypts or decrypts, depending on the mode already set, a designated array of bytes and returns the result.
Parameters:
data - the data to encrypt/decrypt.
Returns:
the decrypted/encrypted result.
Throws:
ConfidentialityException - if an exception occurs duirng the process.

doFinal

public byte[] doFinal(byte[] data,
                      int offset,
                      int length)
            throws ConfidentialityException
Encrypts or decrypts, depending on the mode already set, a designated array of bytes and returns the result.
Parameters:
data - the data to encrypt/decrypt.
offset - where to start in data.
length - how many bytes to consider in data.
Returns:
the decrypted/encrypted result.
Throws:
ConfidentialityException - if an exception occurs duirng the process.

init

public void init(KDF kdf,
                 byte[] iv,
                 Direction dir)
            throws SaslException
Initialises a SASL-SRP CALG implementation.
Parameters:
kdf - the key derivation function.
iv - the initial vector value to use.
dir - whether this CALG is used for encryption or decryption.

CALG.java -- Copyright (C) 2003, 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.