Examples of DSAParams


Examples of java.security.interfaces.DSAParams

        if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
            throw new InvalidKeyException(
                    Messages.getString("security.16C")); //$NON-NLS-1$
        }

        DSAParams params = ((DSAPublicKey) publicKey).getParams();
        p = params.getP();
        q = params.getQ();
        y = ((DSAPublicKey) publicKey).getY();

        // checks described in DSA standard
        n1 = p.bitLength();
        if (p.compareTo(BigInteger.valueOf(1)) != 1 || n1 < 512 || n1 > 1024
View Full Code Here

Examples of java.security.interfaces.DSAParams

        byte randomBytes[];
        byte rBytes[], sBytes[], signature[];

        int n, n1, n2;

        DSAParams params;

        if (appRandom == null) {
            appRandom = new SecureRandom();
        }

        params = dsaKey.getParams();
        p = params.getP();
        q = params.getQ();
        g = params.getG();
        x = ((DSAPrivateKey) dsaKey).getX();

        // forming signature according algorithm described in chapter 5 of DSA standard

        digestBI = new BigInteger(1, msgDigest.digest());
View Full Code Here

Examples of java.security.interfaces.DSAParams

        BigInteger u1, u2, v;

        // parameters and public key
        BigInteger p, q, g, y;

        DSAParams params;

        int n1, n2;

        byte bytes[];
        byte digest[];

        // checking up on signature's ASN1
        try {
            byte dummy;
            n1 = sigBytes[offset + 3];
            n2 = sigBytes[offset + n1 + 5];

            if (sigBytes[offset + 0] != 0x30 || sigBytes[offset + 2] != 2
                    || sigBytes[offset + n1 + 4] != 2
                    || sigBytes[offset + 1] != (n1 + n2 + 4) || n1 > 21
                    || n2 > 21
                    || (length != 0 && (sigBytes[offset + 1] + 2) > length)) {
                throw new SignatureException(Messages.getString("security.16F")); //$NON-NLS-1$
            }

            dummy = sigBytes[5 + n1 + n2]; // to check length of sigBytes
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new SignatureException(Messages.getString("security.170")); //$NON-NLS-1$
        }

        digest = msgDigest.digest();

        bytes = new byte[n1];
        System.arraycopy(sigBytes, offset + 4, bytes, 0, n1);
        r = new BigInteger(bytes);

        bytes = new byte[n2];
        System.arraycopy(sigBytes, offset + 6 + n1, bytes, 0, n2);
        s = new BigInteger(bytes);

        params = dsaKey.getParams();
        p = params.getP();
        q = params.getQ();
        g = params.getG();
        y = ((DSAPublicKey) dsaKey).getY();

        // forming signature according algorithm described in chapter 6 of DSA standard

        if (r.signum() != 1 || r.compareTo(q) != -1 || s.signum() != 1
View Full Code Here

Examples of java.security.interfaces.DSAParams

                if (keySpec.equals(DSAPrivateKeySpec.class)) {

                    x = privateKey.getX();

                    DSAParams params = privateKey.getParams();

                    p = params.getP();
                    q = params.getQ();
                    g = params.getG();

                    return (T) (new DSAPrivateKeySpec(x, p, q, g));
                }

                if (keySpec.equals(PKCS8EncodedKeySpec.class)) {
                    return (T) (new PKCS8EncodedKeySpec(key.getEncoded()));
                }

                throw new InvalidKeySpecException(Messages
                        .getString("security.19C")); //$NON-NLS-1$
            }

            if (key instanceof DSAPublicKey) {
                DSAPublicKey publicKey = (DSAPublicKey) key;

                if (keySpec.equals(DSAPublicKeySpec.class)) {

                    y = publicKey.getY();

                    DSAParams params = publicKey.getParams();

                    p = params.getP();
                    q = params.getQ();
                    g = params.getG();

                    return (T) (new DSAPublicKeySpec(y, p, q, g));
                }

                if (keySpec.equals(X509EncodedKeySpec.class)) {
View Full Code Here

Examples of java.security.interfaces.DSAParams

        if (key != null) {
            if (key instanceof DSAPrivateKey) {

                DSAPrivateKey privateKey = (DSAPrivateKey) key;
                DSAParams params = privateKey.getParams();

                try {
                    return engineGeneratePrivate(new DSAPrivateKeySpec(
                            privateKey.getX(), params.getP(), params.getQ(),
                            params.getG()));
                } catch (InvalidKeySpecException e) {
                    // Actually this exception shouldn't be thrown
                    throw new InvalidKeyException(Messages.getString(
                            "security.1A0", e)); //$NON-NLS-1$
                }
            }

            if (key instanceof DSAPublicKey) {

                DSAPublicKey publicKey = (DSAPublicKey) key;
                DSAParams params = publicKey.getParams();

                try {
                    return engineGeneratePublic(new DSAPublicKeySpec(publicKey
                            .getY(), params.getP(), params.getQ(), params
                            .getG()));
                } catch (InvalidKeySpecException e) {
                    // Actually this exception shouldn't be thrown
                    throw new InvalidKeyException(Messages.getString(
                            "security.1A1", e)); //$NON-NLS-1$
View Full Code Here

Examples of java.security.interfaces.DSAParams

     *    InvalidKeyException if privateKey is not DSAPrivateKey object
     */
    protected void engineInitSign(PrivateKey privateKey)
            throws InvalidKeyException {

        DSAParams params;

        // parameters and private key
        BigInteger p, q, x;

        int n;

        if (privateKey == null || !(privateKey instanceof DSAPrivateKey)) {
            throw new InvalidKeyException(
                    Messages.getString("security.168")); //$NON-NLS-1$
        }

        params = ((DSAPrivateKey) privateKey).getParams();
        p = params.getP();
        q = params.getQ();
        x = ((DSAPrivateKey) privateKey).getX();

        // checks described in DSA standard
        n = p.bitLength();
        if (p.compareTo(BigInteger.valueOf(1)) != 1 || n < 512 || n > 1024
View Full Code Here

Examples of java.security.interfaces.DSAParams

        if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
            throw new InvalidKeyException(
                    Messages.getString("security.16C")); //$NON-NLS-1$
        }

        DSAParams params = ((DSAPublicKey) publicKey).getParams();
        p = params.getP();
        q = params.getQ();
        y = ((DSAPublicKey) publicKey).getY();

        // checks described in DSA standard
        n1 = p.bitLength();
        if (p.compareTo(BigInteger.valueOf(1)) != 1 || n1 < 512 || n1 > 1024
View Full Code Here

Examples of java.security.interfaces.DSAParams

        byte randomBytes[];
        byte rBytes[], sBytes[], signature[];

        int n, n1, n2;

        DSAParams params;

        if (appRandom == null) {
            appRandom = new SecureRandom();
        }

        params = dsaKey.getParams();
        p = params.getP();
        q = params.getQ();
        g = params.getG();
        x = ((DSAPrivateKey) dsaKey).getX();

        // forming signature according algorithm described in chapter 5 of DSA standard

        digestBI = new BigInteger(1, msgDigest.digest());
View Full Code Here

Examples of java.security.interfaces.DSAParams

        BigInteger u1, u2, v;

        // parameters and public key
        BigInteger p, q, g, y;

        DSAParams params;

        int n1, n2;

        byte bytes[];
        byte digest[];

        // checking up on signature's ASN1
        try {
            byte dummy;
            n1 = sigBytes[offset + 3];
            n2 = sigBytes[offset + n1 + 5];

            if (sigBytes[offset + 0] != 0x30 || sigBytes[offset + 2] != 2
                    || sigBytes[offset + n1 + 4] != 2
                    || sigBytes[offset + 1] != (n1 + n2 + 4) || n1 > 21
                    || n2 > 21
                    || (length != 0 && (sigBytes[offset + 1] + 2) > length)) {
                throw new SignatureException(Messages.getString("security.16F")); //$NON-NLS-1$
            }

            dummy = sigBytes[5 + n1 + n2]; // to check length of sigBytes
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new SignatureException(Messages.getString("security.170")); //$NON-NLS-1$
        }

        digest = msgDigest.digest();

        bytes = new byte[n1];
        System.arraycopy(sigBytes, offset + 4, bytes, 0, n1);
        r = new BigInteger(bytes);

        bytes = new byte[n2];
        System.arraycopy(sigBytes, offset + 6 + n1, bytes, 0, n2);
        s = new BigInteger(bytes);

        params = dsaKey.getParams();
        p = params.getP();
        q = params.getQ();
        g = params.getG();
        y = ((DSAPublicKey) dsaKey).getY();

        // forming signature according algorithm described in chapter 6 of DSA standard

        if (r.signum() != 1 || r.compareTo(q) != -1 || s.signum() != 1
View Full Code Here

Examples of java.security.interfaces.DSAParams

                if (keySpec.equals(DSAPrivateKeySpec.class)) {

                    x = privateKey.getX();

                    DSAParams params = privateKey.getParams();

                    p = params.getP();
                    q = params.getQ();
                    g = params.getG();

                    return (T) (new DSAPrivateKeySpec(x, p, q, g));
                }

                if (keySpec.equals(PKCS8EncodedKeySpec.class)) {
                    return (T) (new PKCS8EncodedKeySpec(key.getEncoded()));
                }

                throw new InvalidKeySpecException(Messages
                        .getString("security.19C")); //$NON-NLS-1$
            }

            if (key instanceof DSAPublicKey) {
                DSAPublicKey publicKey = (DSAPublicKey) key;

                if (keySpec.equals(DSAPublicKeySpec.class)) {

                    y = publicKey.getY();

                    DSAParams params = publicKey.getParams();

                    p = params.getP();
                    q = params.getQ();
                    g = params.getG();

                    return (T) (new DSAPublicKeySpec(y, p, q, g));
                }

                if (keySpec.equals(X509EncodedKeySpec.class)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.