## net.i2p.crypto
Class DSAEngine

    java.lang.Object
      net.i2p.crypto.DSAEngine

Direct Known Subclasses:
  DummyDSAEngine

    public class DSAEngine

extends Object

Sign and verify using DSA-SHA1. Also contains methods to sign and verify using a SHA-256 Hash, used by Syndie only. The primary implementation is code from TheCryto. As of 0.8.7, also included is an alternate implementation using java.security libraries, which is slightly slower. This implementation could in the future be easily modified to use a new signing algorithm from java.security when we change the signing algorithm. Params and rv's changed from Hash to SHA1Hash for version 0.8.1 Hash variants of sign() and verifySignature() restored in 0.8.3, required by Syndie.

Constructor Summary
`DSAEngine(I2PAppContext context)`

Method Summary
`static SHA1Hash` `calculateHash(byte[] source, int offset, int len)`
`SHA1Hash` `calculateHash(InputStream in)` Reads the stream until EOF.
`static DSAEngine` `getInstance()`
`static void` `main(String[] args)` Run consistency and speed tests with both TheCrypto and java.security libraries.
`Signature` `sign(byte[] data, int offset, int length, SigningPrivateKey signingKey)` Sign using DSA-SHA1
`Signature` `sign(byte[] data, SigningPrivateKey signingKey)` Sign using DSA-SHA1.
`Signature` `sign(Hash hash, SigningPrivateKey signingKey)` Used by Syndie.
`Signature` `sign(InputStream in, SigningPrivateKey signingKey)` Sign using DSA-SHA1.
`Signature` `sign(SHA1Hash hash, SigningPrivateKey signingKey)`
`boolean` `verifySignature(Signature signature, byte[] signedData, int offset, int size, SigningPublicKey verifyingKey)` Verify using DSA-SHA1
`boolean` `verifySignature(Signature signature, byte[] signedData, SigningPublicKey verifyingKey)` Verify using DSA-SHA1.
`boolean` `verifySignature(Signature signature, Hash hash, SigningPublicKey verifyingKey)` Used by Syndie.
`boolean` `verifySignature(Signature signature, InputStream in, SigningPublicKey verifyingKey)` Verify using DSA-SHA1
`boolean` `verifySignature(Signature signature, SHA1Hash hash, SigningPublicKey verifyingKey)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DSAEngine

    public DSAEngine(I2PAppContext context)

Method Detail

### getInstance

    public static DSAEngine getInstance()

### verifySignature

    public boolean verifySignature(Signature signature,
                                   byte[] signedData,
                                   SigningPublicKey verifyingKey)

  Verify using DSA-SHA1. Uses TheCrypto code unless configured to use the java.security libraries.

### verifySignature

    public boolean verifySignature(Signature signature,
                                   byte[] signedData,
                                   int offset,
                                   int size,
                                   SigningPublicKey verifyingKey)

  Verify using DSA-SHA1

### verifySignature

    public boolean verifySignature(Signature signature,
                                   InputStream in,
                                   SigningPublicKey verifyingKey)

  Verify using DSA-SHA1

### verifySignature

    public boolean verifySignature(Signature signature,
                                   SHA1Hash hash,
                                   SigningPublicKey verifyingKey)

  Parameters:
    `hash` - SHA-1 hash, NOT a SHA-256 hash

### verifySignature

    public boolean verifySignature(Signature signature,
                                   Hash hash,
                                   SigningPublicKey verifyingKey)

  Used by Syndie.

  Since:
    0.8.3 (restored, was removed in 0.8.1 and 0.8.2)

### sign

    public Signature sign(byte[] data,
                          SigningPrivateKey signingKey)

  Sign using DSA-SHA1. Uses TheCrypto code unless configured to use the java.security libraries.

### sign

    public Signature sign(byte[] data,
                          int offset,
                          int length,
                          SigningPrivateKey signingKey)

  Sign using DSA-SHA1

### sign

    public Signature sign(InputStream in,
                          SigningPrivateKey signingKey)

  Sign using DSA-SHA1. Reads the stream until EOF. Does not close the stream.

### sign

    public Signature sign(SHA1Hash hash,
                          SigningPrivateKey signingKey)

  Parameters:
    `hash` - SHA-1 hash, NOT a SHA-256 hash

### sign

    public Signature sign(Hash hash,
                          SigningPrivateKey signingKey)

  Used by Syndie.

  Since:
    0.8.3 (restored, was removed in 0.8.1 and 0.8.2)

### calculateHash

    public SHA1Hash calculateHash(InputStream in)

  Reads the stream until EOF. Does not close the stream.

  Returns:
    hash SHA-1 hash, NOT a SHA-256 hash

### calculateHash

    public static SHA1Hash calculateHash(byte[] source,
                                         int offset,
                                         int len)

  Returns:
    hash SHA-1 hash, NOT a SHA-256 hash

### main

    public static void main(String[] args)

  Run consistency and speed tests with both TheCrypto and java.security libraries. TheCrypto is about 5-15% faster than java.security.