FileDocCategorySizeDatePackage
XYZSign.javaAPI DocExample3832Sun Oct 25 18:13:36 GMT 1998None

XYZSign

public class XYZSign extends Signature implements Cloneable

Fields Summary
private DSAPublicKey
pub
private DSAPrivateKey
priv
private MessageDigest
md
Constructors Summary
public XYZSign()

		super("XYZSign");
		md = MessageDigest.getInstance("SHA");
	
Methods Summary
private byte[]crypt(byte[] s, java.security.interfaces.DSAKey key)

		DSAParams p = key.getParams();
		int rotValue = p.getP().intValue();
		byte d[] = rot(s, (byte) rotValue);
		return d;
	
public java.lang.ObjectengineGetParameter(java.lang.String param)

		throw new InvalidParameterException("No parameters");
	
public voidengineInitSign(java.security.PrivateKey privateKey)

		try {
			priv = (DSAPrivateKey) privateKey;
		} catch (ClassCastException cce) {
			throw new InvalidKeyException("Wrong private key type");
		}
	
public voidengineInitVerify(java.security.PublicKey publicKey)

		try {
			pub = (DSAPublicKey) publicKey;
		} catch (ClassCastException cce) {
			throw new InvalidKeyException("Wrong public key type");
		}
	
public voidengineReset()

	
public voidengineSetParameter(java.lang.String param, java.lang.Object value)

		throw new InvalidParameterException("No parameters");
	
public voidengineSetParameter(java.security.spec.AlgorithmParameterSpec aps)

		throw new InvalidParameterException("No parameters");
	
public byte[]engineSign()

		byte b[] = null;
		try {
			b = md.digest();
		} catch (NullPointerException npe) {
			throw new SignatureException("No SHA digest found");
		}
		return crypt(b, priv);
	
public voidengineUpdate(byte b)

		try {
			md.update(b);
		} catch (NullPointerException npe) {
			throw new SignatureException("No SHA digest found");
		}
	
public voidengineUpdate(byte[] b, int offset, int length)

		try {
			md.update(b, offset, length);
		} catch (NullPointerException npe) {
			throw new SignatureException("No SHA digest found");
		}
	
public booleanengineVerify(byte[] sigBytes)

		byte b[] = null;
		try {
			b = md.digest();
		} catch (NullPointerException npe) {
			throw new SignatureException("No SHA digest found");
		}
		byte sig[] = crypt(sigBytes, pub);
		return MessageDigest.isEqual(sig, b);
	
private byte[]rot(byte[] in, byte rotValue)

		byte out[] = new byte[in.length];
		for (int i = 0; i < in.length; i++) {
			out[i] = (byte) (in[i] ^ rotValue);
		}
		return out;