Package org.apache.sshd.common.mac
Class Poly1305Mac
- java.lang.Object
-
- org.apache.sshd.common.mac.Poly1305Mac
-
- All Implemented Interfaces:
AlgorithmNameProvider,Mac,MacInformation
public class Poly1305Mac extends java.lang.Object implements Mac
Poly1305 one-time message authentication code. This implementation is derived from the public domain C library poly1305-donna.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBLOCK_SIZEprivate byte[]currentBlockprivate intcurrentBlockOffsetprivate inth0private inth1private inth2private inth3private inth4private intk0private intk1private intk2private intk3static intKEY_BYTESprivate intr0private intr1private intr2private intr3private intr4private ints1private ints2private ints3private ints4
-
Constructor Summary
Constructors Constructor Description Poly1305Mac()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoFinal(byte[] out, int offset)java.lang.StringgetAlgorithm()intgetBlockSize()intgetDefaultBlockSize()voidinit(byte[] key)private static voidpackIntLE(int value, byte[] dst, int off)private voidprocessBlock()private voidreset()private static intunpackIntLE(byte[] buf, int off)private static longunsignedProduct(int i1, int i2)voidupdate(byte[] in, int offset, int length)voidupdateUInt(long value)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.mac.MacInformation
isEncryptThenMac
-
-
-
-
Field Detail
-
KEY_BYTES
public static final int KEY_BYTES
- See Also:
- Constant Field Values
-
BLOCK_SIZE
private static final int BLOCK_SIZE
- See Also:
- Constant Field Values
-
r0
private int r0
-
r1
private int r1
-
r2
private int r2
-
r3
private int r3
-
r4
private int r4
-
s1
private int s1
-
s2
private int s2
-
s3
private int s3
-
s4
private int s4
-
k0
private int k0
-
k1
private int k1
-
k2
private int k2
-
k3
private int k3
-
h0
private int h0
-
h1
private int h1
-
h2
private int h2
-
h3
private int h3
-
h4
private int h4
-
currentBlock
private final byte[] currentBlock
-
currentBlockOffset
private int currentBlockOffset
-
-
Method Detail
-
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithmin interfaceAlgorithmNameProvider
-
init
public void init(byte[] key) throws java.lang.Exception
-
updateUInt
public void updateUInt(long value)
- Specified by:
updateUIntin interfaceMac
-
doFinal
public void doFinal(byte[] out, int offset) throws java.lang.Exception
-
processBlock
private void processBlock()
-
reset
private void reset()
-
getBlockSize
public int getBlockSize()
- Specified by:
getBlockSizein interfaceMacInformation- Returns:
- MAC output block size in bytes - may be less than the default - e.g., MD5-96
-
getDefaultBlockSize
public int getDefaultBlockSize()
- Specified by:
getDefaultBlockSizein interfaceMacInformation- Returns:
- The "natural" MAC block size in bytes
-
unpackIntLE
private static int unpackIntLE(byte[] buf, int off)
-
packIntLE
private static void packIntLE(int value, byte[] dst, int off)
-
unsignedProduct
private static long unsignedProduct(int i1, int i2)
-
-