Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org> Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. From-SVN: r116139
This commit is contained in:
parent
abab460491
commit
ac1ed908de
1294 changed files with 99479 additions and 35933 deletions
|
@ -55,72 +55,65 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* <p>The DSS (Digital Signature Standard) algorithm makes use of the following
|
||||
* parameters:</p>
|
||||
*
|
||||
* The DSS (Digital Signature Standard) algorithm makes use of the following
|
||||
* parameters:
|
||||
* <ol>
|
||||
* <li>p: A prime modulus, where <code>2<sup>L-1</sup> < p < 2<sup>L</sup>
|
||||
* </code> for <code>512 <= L <= 1024</code> and <code>L</code> a
|
||||
* multiple of <code>64</code>.</li>
|
||||
* <li>q: A prime divisor of <code>p - 1</code>, where <code>2<sup>159</sup>
|
||||
* <li>p: A prime modulus, where
|
||||
* <code>2<sup>L-1</sup> < p < 2<sup>L</sup> </code> for <code>512 <= L
|
||||
* <= 1024</code> and <code>L</code> a multiple of <code>64</code>.</li>
|
||||
* <li>q: A prime divisor of <code>p - 1</code>, where <code>2<sup>159</sup>
|
||||
* < q < 2<sup>160</sup></code>.</li>
|
||||
* <li>g: Where <code>g = h<sup>(p-1)</sup>/q mod p</code>, where
|
||||
* <code>h</code> is any integer with <code>1 < h < p - 1</code> such
|
||||
* that <code>h<sup> (p-1)</sup>/q mod p > 1</code> (<code>g</code> has order
|
||||
* <code>q mod p</code>).</li>
|
||||
* <li>x: A randomly or pseudorandomly generated integer with <code>0 < x
|
||||
* <li>g: Where <code>g = h<sup>(p-1)</sup>/q mod p</code>, where
|
||||
* <code>h</code> is any integer with <code>1 < h < p - 1</code> such
|
||||
* that <code>h<sup> (p-1)</sup>/q mod p > 1</code> (<code>g</code> has order
|
||||
* <code>q mod p</code>).</li>
|
||||
* <li>x: A randomly or pseudorandomly generated integer with <code>0 < x
|
||||
* < q</code>.</li>
|
||||
* <li>y: <code>y = g<sup>x</sup> mod p</code>.</li>
|
||||
* <li>k: A randomly or pseudorandomly generated integer with <code>0 < k
|
||||
* <li>y: <code>y = g<sup>x</sup> mod p</code>.</li>
|
||||
* <li>k: A randomly or pseudorandomly generated integer with <code>0 < k
|
||||
* < q</code>.</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p>The integers <code>p</code>, <code>q</code>, and <code>g</code> can be
|
||||
* <p>
|
||||
* The integers <code>p</code>, <code>q</code>, and <code>g</code> can be
|
||||
* public and can be common to a group of users. A user's private and public
|
||||
* keys are <code>x</code> and <code>y</code>, respectively. They are normally
|
||||
* fixed for a period of time. Parameters <code>x</code> and <code>k</code> are
|
||||
* used for signature generation only, and must be kept secret. Parameter
|
||||
* <code>k</code> must be regenerated for each signature.</p>
|
||||
*
|
||||
* <p>The signature of a message <code>M</code> is the pair of numbers <code>r</code>
|
||||
* and <code>s</code> computed according to the equations below:</p>
|
||||
*
|
||||
* keys are <code>x</code> and <code>y</code>, respectively. They are
|
||||
* normally fixed for a period of time. Parameters <code>x</code> and
|
||||
* <code>k</code> are used for signature generation only, and must be kept
|
||||
* secret. Parameter <code>k</code> must be regenerated for each signature.
|
||||
* <p>
|
||||
* The signature of a message <code>M</code> is the pair of numbers
|
||||
* <code>r</code> and <code>s</code> computed according to the equations below:
|
||||
* <ul>
|
||||
* <li><code>r = (g<sup>k</sup> mod p) mod q</code> and</li>
|
||||
* <li><code>s = (k<sup>-1</sup>(SHA(M) + xr)) mod q</code>.</li>
|
||||
* <li><code>r = (g<sup>k</sup> mod p) mod q</code> and</li>
|
||||
* <li><code>s = (k<sup>-1</sup>(SHA(M) + xr)) mod q</code>.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>In the above, <code>k<sup>-1</sup></code> is the multiplicative inverse of
|
||||
* <code>k</code>, <code>mod q</code>; i.e., <code>(k<sup>-1</sup> k) mod q = 1
|
||||
* </code> and <code>0 < k-1 < q</code>. The value of <code>SHA(M)</code>
|
||||
* is a 160-bit string output by the Secure Hash Algorithm specified in FIPS 180.
|
||||
* For use in computing <code>s</code>, this string must be converted to an
|
||||
* integer.</p>
|
||||
*
|
||||
* <p>As an option, one may wish to check if <code>r == 0</code> or <code>s == 0
|
||||
* </code>. If either <code>r == 0</code> or <code>s == 0</code>, a new value
|
||||
* of <code>k</code> should be generated and the signature should be
|
||||
* recalculated (it is extremely unlikely that <code>r == 0</code> or <code>s ==
|
||||
* 0</code> if signatures are generated properly).</p>
|
||||
*
|
||||
* <p>The signature is transmitted along with the message to the verifier.</p>
|
||||
*
|
||||
* <p>References:</p>
|
||||
* <p>
|
||||
* In the above, <code>k<sup>-1</sup></code> is the multiplicative inverse of
|
||||
* <code>k</code>, <code>mod q</code>; i.e., <code>(k<sup>-1</sup> k) mod q =
|
||||
* 1</code> and <code>0 < k-1 < q</code>. The value of <code>SHA(M)</code>
|
||||
* is a 160-bit string output by the Secure Hash Algorithm specified in FIPS
|
||||
* 180. For use in computing <code>s</code>, this string must be converted to
|
||||
* an integer.
|
||||
* <p>
|
||||
* As an option, one may wish to check if <code>r == 0</code> or <code>s == 0
|
||||
* </code>.
|
||||
* If either <code>r == 0</code> or <code>s == 0</code>, a new value of
|
||||
* <code>k</code> should be generated and the signature should be recalculated
|
||||
* (it is extremely unlikely that <code>r == 0</code> or <code>s == 0</code> if
|
||||
* signatures are generated properly).
|
||||
* <p>
|
||||
* The signature is transmitted along with the message to the verifier.
|
||||
* <p>
|
||||
* References:
|
||||
* <ol>
|
||||
* <li><a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital
|
||||
* Signature Standard (DSS)</a>, Federal Information Processing Standards
|
||||
* Publication 186. National Institute of Standards and Technology.</li>
|
||||
* <li><a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital Signature
|
||||
* Standard (DSS)</a>, Federal Information Processing Standards Publication
|
||||
* 186. National Institute of Standards and Technology.</li>
|
||||
* </ol>
|
||||
*/
|
||||
public class DSSSignature extends BaseSignature
|
||||
public class DSSSignature
|
||||
extends BaseSignature
|
||||
{
|
||||
|
||||
// Constants and variables
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Constructor(s)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** Trivial 0-arguments constructor. */
|
||||
public DSSSignature()
|
||||
{
|
||||
|
@ -137,16 +130,12 @@ public class DSSSignature extends BaseSignature
|
|||
this.md = (IMessageDigest) that.md.clone();
|
||||
}
|
||||
|
||||
// Class methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public static final BigInteger[] sign(final DSAPrivateKey k, final byte[] h)
|
||||
{
|
||||
final DSSSignature sig = new DSSSignature();
|
||||
final Map attributes = new HashMap();
|
||||
attributes.put(ISignature.SIGNER_KEY, k);
|
||||
sig.setupSign(attributes);
|
||||
|
||||
return sig.computeRS(h);
|
||||
}
|
||||
|
||||
|
@ -157,11 +146,9 @@ public class DSSSignature extends BaseSignature
|
|||
final Map attributes = new HashMap();
|
||||
attributes.put(ISignature.SIGNER_KEY, k);
|
||||
if (rnd != null)
|
||||
{
|
||||
attributes.put(ISignature.SOURCE_OF_RANDOMNESS, rnd);
|
||||
}
|
||||
sig.setupSign(attributes);
|
||||
attributes.put(ISignature.SOURCE_OF_RANDOMNESS, rnd);
|
||||
|
||||
sig.setupSign(attributes);
|
||||
return sig.computeRS(h);
|
||||
}
|
||||
|
||||
|
@ -172,11 +159,9 @@ public class DSSSignature extends BaseSignature
|
|||
final Map attributes = new HashMap();
|
||||
attributes.put(ISignature.SIGNER_KEY, k);
|
||||
if (irnd != null)
|
||||
{
|
||||
attributes.put(ISignature.SOURCE_OF_RANDOMNESS, irnd);
|
||||
}
|
||||
sig.setupSign(attributes);
|
||||
attributes.put(ISignature.SOURCE_OF_RANDOMNESS, irnd);
|
||||
|
||||
sig.setupSign(attributes);
|
||||
return sig.computeRS(h);
|
||||
}
|
||||
|
||||
|
@ -187,13 +172,9 @@ public class DSSSignature extends BaseSignature
|
|||
final Map attributes = new HashMap();
|
||||
attributes.put(ISignature.VERIFIER_KEY, k);
|
||||
sig.setupVerify(attributes);
|
||||
|
||||
return sig.checkRS(rs, h);
|
||||
}
|
||||
|
||||
// Implementation of abstract methods in superclass
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new DSSSignature(this);
|
||||
|
@ -202,81 +183,37 @@ public class DSSSignature extends BaseSignature
|
|||
protected void setupForVerification(PublicKey k)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (!(k instanceof DSAPublicKey))
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (! (k instanceof DSAPublicKey))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.publicKey = k;
|
||||
}
|
||||
|
||||
protected void setupForSigning(PrivateKey k) throws IllegalArgumentException
|
||||
{
|
||||
if (!(k instanceof DSAPrivateKey))
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (! (k instanceof DSAPrivateKey))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.privateKey = k;
|
||||
}
|
||||
|
||||
protected Object generateSignature() throws IllegalStateException
|
||||
{
|
||||
// BigInteger p = ((DSAPrivateKey) privateKey).getParams().getP();
|
||||
// BigInteger q = ((DSAPrivateKey) privateKey).getParams().getQ();
|
||||
// BigInteger g = ((DSAPrivateKey) privateKey).getParams().getG();
|
||||
// BigInteger x = ((DSAPrivateKey) privateKey).getX();
|
||||
// BigInteger m = new BigInteger(1, md.digest());
|
||||
// BigInteger k, r, s;
|
||||
//
|
||||
// byte[] kb = new byte[20]; // we'll use 159 bits only
|
||||
// while (true) {
|
||||
// this.nextRandomBytes(kb);
|
||||
// k = new BigInteger(1, kb);
|
||||
// k.clearBit(159);
|
||||
// r = g.modPow(k, p).mod(q);
|
||||
// if (r.equals(BigInteger.ZERO)) {
|
||||
// continue;
|
||||
// }
|
||||
// s = m.add(x.multiply(r)).multiply(k.modInverse(q)).mod(q);
|
||||
// if (s.equals(BigInteger.ZERO)) {
|
||||
// continue;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
final BigInteger[] rs = computeRS(md.digest());
|
||||
|
||||
// return encodeSignature(r, s);
|
||||
return encodeSignature(rs[0], rs[1]);
|
||||
}
|
||||
|
||||
protected boolean verifySignature(Object sig) throws IllegalStateException
|
||||
{
|
||||
final BigInteger[] rs = decodeSignature(sig);
|
||||
// BigInteger r = rs[0];
|
||||
// BigInteger s = rs[1];
|
||||
//
|
||||
// BigInteger g = ((DSAPublicKey) publicKey).getParams().getG();
|
||||
// BigInteger p = ((DSAPublicKey) publicKey).getParams().getP();
|
||||
// BigInteger q = ((DSAPublicKey) publicKey).getParams().getQ();
|
||||
// BigInteger y = ((DSAPublicKey) publicKey).getY();
|
||||
// BigInteger w = s.modInverse(q);
|
||||
//
|
||||
// byte bytes[] = md.digest();
|
||||
// BigInteger u1 = w.multiply(new BigInteger(1, bytes)).mod(q);
|
||||
// BigInteger u2 = r.multiply(w).mod(q);
|
||||
//
|
||||
// BigInteger v = g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
|
||||
// return v.equals(r);
|
||||
return checkRS(rs, md.digest());
|
||||
}
|
||||
|
||||
// Other instance methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the output of a signature generation phase.<p>
|
||||
*
|
||||
* Returns the output of a signature generation phase.
|
||||
*
|
||||
* @return an object encapsulating the DSS signature pair <code>r</code> and
|
||||
* <code>s</code>.
|
||||
* <code>s</code>.
|
||||
*/
|
||||
private Object encodeSignature(BigInteger r, BigInteger s)
|
||||
{
|
||||
|
@ -284,9 +221,9 @@ public class DSSSignature extends BaseSignature
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the output of a previously generated signature object as a pair
|
||||
* of {@link java.math.BigInteger}.<p>
|
||||
*
|
||||
* Returns the output of a previously generated signature object as a pair of
|
||||
* {@link java.math.BigInteger}.
|
||||
*
|
||||
* @return the DSS signature pair <code>r</code> and <code>s</code>.
|
||||
*/
|
||||
private BigInteger[] decodeSignature(Object signature)
|
||||
|
@ -302,7 +239,6 @@ public class DSSSignature extends BaseSignature
|
|||
final BigInteger x = ((DSAPrivateKey) privateKey).getX();
|
||||
final BigInteger m = new BigInteger(1, digestBytes);
|
||||
BigInteger k, r, s;
|
||||
|
||||
final byte[] kb = new byte[20]; // we'll use 159 bits only
|
||||
while (true)
|
||||
{
|
||||
|
@ -311,17 +247,14 @@ public class DSSSignature extends BaseSignature
|
|||
k.clearBit(159);
|
||||
r = g.modPow(k, p).mod(q);
|
||||
if (r.equals(BigInteger.ZERO))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
s = m.add(x.multiply(r)).multiply(k.modInverse(q)).mod(q);
|
||||
if (s.equals(BigInteger.ZERO))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return new BigInteger[] { r, s };
|
||||
}
|
||||
|
||||
|
@ -329,16 +262,13 @@ public class DSSSignature extends BaseSignature
|
|||
{
|
||||
final BigInteger r = rs[0];
|
||||
final BigInteger s = rs[1];
|
||||
|
||||
final BigInteger g = ((DSAPublicKey) publicKey).getParams().getG();
|
||||
final BigInteger p = ((DSAPublicKey) publicKey).getParams().getP();
|
||||
final BigInteger q = ((DSAPublicKey) publicKey).getParams().getQ();
|
||||
final BigInteger y = ((DSAPublicKey) publicKey).getY();
|
||||
final BigInteger w = s.modInverse(q);
|
||||
|
||||
final BigInteger u1 = w.multiply(new BigInteger(1, digestBytes)).mod(q);
|
||||
final BigInteger u2 = r.multiply(w).mod(q);
|
||||
|
||||
final BigInteger v = g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
|
||||
return v.equals(r);
|
||||
}
|
||||
|
|
|
@ -45,61 +45,46 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* <p>An object that implements the {@link ISignatureCodec} operations for the
|
||||
* <i>Raw</i> format to use with DSS signatures.</p>
|
||||
* An object that implements the {@link ISignatureCodec} operations for the
|
||||
* <i>Raw</i> format to use with DSS signatures.
|
||||
*/
|
||||
public class DSSSignatureRawCodec implements ISignatureCodec
|
||||
public class DSSSignatureRawCodec
|
||||
implements ISignatureCodec
|
||||
{
|
||||
|
||||
// Constants and variables
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Constructor(s)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// implicit 0-arguments constructor
|
||||
|
||||
// Class methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Instance methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// gnu.crypto.sig.ISignatureCodec interface implementation -----------------
|
||||
|
||||
public int getFormatID()
|
||||
{
|
||||
return RAW_FORMAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the encoded form of the designated DSS (Digital Signature
|
||||
* Standard) signature object according to the <i>Raw</i> format supported by
|
||||
* this library.</p>
|
||||
*
|
||||
* <p>The <i>Raw</i> format for a DSA signature, in this implementation, is a
|
||||
* byte sequence consisting of the following:</p>
|
||||
*
|
||||
* Returns the encoded form of the designated DSS (Digital Signature Standard)
|
||||
* signature object according to the <i>Raw</i> format supported by this
|
||||
* library.
|
||||
* <p>
|
||||
* The <i>Raw</i> format for a DSA signature, in this implementation, is a
|
||||
* byte sequence consisting of the following:
|
||||
* <ol>
|
||||
* <li>4-byte magic consisting of the value of the literal
|
||||
* {@link Registry#MAGIC_RAW_DSS_SIGNATURE},</li>
|
||||
* <li>1-byte version consisting of the constant: 0x01,</li>
|
||||
* <li>4-byte count of following bytes representing the DSS parameter
|
||||
* <code>r</code> in internet order,</li>
|
||||
* <li>n-bytes representation of a {@link BigInteger} obtained by invoking
|
||||
* the <code>toByteArray()</code> method on the DSS parameter <code>r</code>,</li>
|
||||
* <li>4-byte count of following bytes representing the DSS parameter
|
||||
* <code>s</code>,</li>
|
||||
* <li>n-bytes representation of a {@link BigInteger} obtained by invoking
|
||||
* the <code>toByteArray()</code> method on the DSS parameter <code>s</code>.</li>
|
||||
* <li>4-byte magic consisting of the value of the literal
|
||||
* {@link Registry#MAGIC_RAW_DSS_SIGNATURE},</li>
|
||||
* <li>1-byte version consisting of the constant: 0x01,</li>
|
||||
* <li>4-byte count of following bytes representing the DSS parameter
|
||||
* <code>r</code> in internet order,</li>
|
||||
* <li>n-bytes representation of a {@link BigInteger} obtained by invoking
|
||||
* the <code>toByteArray()</code> method on the DSS parameter <code>r</code>,
|
||||
* </li>
|
||||
* <li>4-byte count of following bytes representing the DSS parameter
|
||||
* <code>s</code>,</li>
|
||||
* <li>n-bytes representation of a {@link BigInteger} obtained by invoking
|
||||
* the <code>toByteArray()</code> method on the DSS parameter <code>s</code>.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* @param signature the signature to encode, consisting of the two DSS
|
||||
* parameters <code>r</code> and <code>s</code> as a {@link java.math.BigInteger}
|
||||
* array.
|
||||
* parameters <code>r</code> and <code>s</code> as a
|
||||
* {@link BigInteger} array.
|
||||
* @return the <i>Raw</i> format encoding of the designated signature.
|
||||
* @exception IllegalArgumentException if the designated signature is not a
|
||||
* DSS (Digital Signature Standard) one.
|
||||
* DSS (Digital Signature Standard) one.
|
||||
*/
|
||||
public byte[] encodeSignature(Object signature)
|
||||
{
|
||||
|
@ -112,38 +97,32 @@ public class DSSSignatureRawCodec implements ISignatureCodec
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
throw new IllegalArgumentException("key");
|
||||
throw new IllegalArgumentException("signature");
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
// magic
|
||||
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[0]);
|
||||
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[1]);
|
||||
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[2]);
|
||||
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[3]);
|
||||
|
||||
// version
|
||||
baos.write(0x01);
|
||||
|
||||
// r
|
||||
byte[] buffer = r.toByteArray();
|
||||
int length = buffer.length;
|
||||
baos.write(length >>> 24);
|
||||
baos.write( length >>> 24);
|
||||
baos.write((length >>> 16) & 0xFF);
|
||||
baos.write((length >>> 8) & 0xFF);
|
||||
baos.write(length & 0xFF);
|
||||
baos.write(buffer, 0, length);
|
||||
|
||||
// s
|
||||
buffer = s.toByteArray();
|
||||
length = buffer.length;
|
||||
baos.write(length >>> 24);
|
||||
baos.write( length >>> 24);
|
||||
baos.write((length >>> 16) & 0xFF);
|
||||
baos.write((length >>> 8) & 0xFF);
|
||||
baos.write(length & 0xFF);
|
||||
baos.write(buffer, 0, length);
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
@ -154,36 +133,32 @@ public class DSSSignatureRawCodec implements ISignatureCodec
|
|||
|| k[1] != Registry.MAGIC_RAW_DSS_SIGNATURE[1]
|
||||
|| k[2] != Registry.MAGIC_RAW_DSS_SIGNATURE[2]
|
||||
|| k[3] != Registry.MAGIC_RAW_DSS_SIGNATURE[3])
|
||||
{
|
||||
throw new IllegalArgumentException("magic");
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("magic");
|
||||
// version
|
||||
if (k[4] != 0x01)
|
||||
{
|
||||
throw new IllegalArgumentException("version");
|
||||
}
|
||||
throw new IllegalArgumentException("version");
|
||||
|
||||
int i = 5;
|
||||
int l;
|
||||
byte[] buffer;
|
||||
|
||||
// r
|
||||
l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
|
||||
| (k[i++] & 0xFF);
|
||||
l = k[i++] << 24
|
||||
| (k[i++] & 0xFF) << 16
|
||||
| (k[i++] & 0xFF) << 8
|
||||
| (k[i++] & 0xFF);
|
||||
buffer = new byte[l];
|
||||
System.arraycopy(k, i, buffer, 0, l);
|
||||
i += l;
|
||||
BigInteger r = new BigInteger(1, buffer);
|
||||
|
||||
// s
|
||||
l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
|
||||
| (k[i++] & 0xFF);
|
||||
l = k[i++] << 24
|
||||
| (k[i++] & 0xFF) << 16
|
||||
| (k[i++] & 0xFF) << 8
|
||||
| (k[i++] & 0xFF);
|
||||
buffer = new byte[l];
|
||||
System.arraycopy(k, i, buffer, 0, l);
|
||||
i += l;
|
||||
BigInteger s = new BigInteger(1, buffer);
|
||||
|
||||
return new BigInteger[] { r, s };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue