当前位置: 首页>>代码示例>>Java>>正文


Java DSAPublicKey.getY方法代码示例

本文整理汇总了Java中java.security.interfaces.DSAPublicKey.getY方法的典型用法代码示例。如果您正苦于以下问题:Java DSAPublicKey.getY方法的具体用法?Java DSAPublicKey.getY怎么用?Java DSAPublicKey.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.interfaces.DSAPublicKey的用法示例。


在下文中一共展示了DSAPublicKey.getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromDSAPublicKey

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
private static byte []
fromDSAPublicKey(DSAPublicKey key) {
	DNSOutput out = new DNSOutput();
	BigInteger q = key.getParams().getQ();
	BigInteger p = key.getParams().getP();
	BigInteger g = key.getParams().getG();
	BigInteger y = key.getY();
	int t = (p.toByteArray().length - 64) / 8;

	out.writeU8(t);
	writeBigInteger(out, q);
	writeBigInteger(out, p);
	writeBigInteger(out, g);
	writeBigInteger(out, y);

	return out.toByteArray();
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:18,代码来源:DNSSEC.java

示例2: buildDSA

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
static byte []
buildDSA(DSAPublicKey key) {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	BigInteger q = key.getParams().getQ();
	BigInteger p = key.getParams().getP();
	BigInteger g = key.getParams().getG();
	BigInteger y = key.getY();
	int t = (p.toByteArray().length - 64) / 8;

	out.write(t);
	writeBigInteger(out, q);
	writeBigInteger(out, p);
	writeBigInteger(out, g);
	writeBigInteger(out, y);

	return out.toByteArray();
}
 
开发者ID:epam,项目名称:Wilma,代码行数:18,代码来源:KEYConverter.java

示例3: DOMKeyValue

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public DOMKeyValue(PublicKey key)  throws KeyException {
    if (key == null) {
        throw new NullPointerException("key cannot be null");
    }
    this.publicKey = key;
    if (key instanceof DSAPublicKey) {
        DSAPublicKey dkey = (DSAPublicKey) key;
        DSAParams params = dkey.getParams();
        p = new DOMCryptoBinary(params.getP());
        q = new DOMCryptoBinary(params.getQ());
        g = new DOMCryptoBinary(params.getG());
        y = new DOMCryptoBinary(dkey.getY());
    } else if (key instanceof RSAPublicKey) {
        RSAPublicKey rkey = (RSAPublicKey) key;
        exponent = new DOMCryptoBinary(rkey.getPublicExponent());
        modulus = new DOMCryptoBinary(rkey.getModulus());
    } else {
        throw new KeyException("unsupported key algorithm: " +
            key.getAlgorithm());
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:22,代码来源:DOMKeyValue.java

示例4: generatePublicKeyParameter

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
static public AsymmetricKeyParameter generatePublicKeyParameter(
    PublicKey    key)
    throws InvalidKeyException
{
    if (key instanceof DSAPublicKey)
    {
        DSAPublicKey    k = (DSAPublicKey)key;

        return new DSAPublicKeyParameters(k.getY(),
            new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
    }

    throw new InvalidKeyException("can't identify DSA public key: " + key.getClass().getName());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:DSAUtil.java

示例5: DSA

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:DOMKeyValue.java

示例6: encodeDsaPublicKeyAsBitString

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
private byte[] encodeDsaPublicKeyAsBitString(DSAPublicKey dsaPublicKey) throws SpkacException {
	try {
		ASN1Integer publicKey = new ASN1Integer(dsaPublicKey.getY());

		return publicKey.getEncoded(ASN1Encoding.DER);
	} catch (Exception ex) {
		throw new SpkacException(res.getString("NoEncodeDsaPublicKey.exception.message"), ex);
	}
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:10,代码来源:Spkac.java

示例7: verify

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
private Boolean verify(byte[] b, PublicKey pubKey, BigInteger r, BigInteger s)
        throws OtrCryptoException {

    if (!(pubKey instanceof DSAPublicKey))
        throw new IllegalArgumentException();

    DSAParams dsaParams = ((DSAPublicKey) pubKey).getParams();

    BigInteger q = dsaParams.getQ();
    DSAParameters bcDSAParams = new DSAParameters(dsaParams.getP(), q, dsaParams.getG());

    DSAPublicKey dsaPrivateKey = (DSAPublicKey) pubKey;
    DSAPublicKeyParameters dsaPrivParms = new DSAPublicKeyParameters(dsaPrivateKey.getY(),
            bcDSAParams);

    // Ian: Note that if you can get the standard DSA implementation you're
    // using to not hash its input, you should be able to pass it ((256-bit
    // value) mod q), (rather than truncating the 256-bit value) and all
    // should be well.
    // ref: Interop problems with libotr - DSA signature
    DSASigner dsaSigner = new DSASigner();
    dsaSigner.init(false, dsaPrivParms);

    BigInteger bmpi = new BigInteger(1, b);
    Boolean result = dsaSigner.verifySignature(BigIntegers.asUnsignedByteArray(bmpi.mod(q)), r,
            s);
    return result;
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:29,代码来源:OtrCryptoEngineImpl.java

示例8: initVerify

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initVerify() {
	if (verifyKey == null) {
		throw new IllegalStateException(
				"Verify key must be set prior to initialization.");
	}

	final DSAPublicKey pubKey = (DSAPublicKey) verifyKey;
	final DSAParams params = pubKey.getParams();
	final DSAPublicKeyParameters bcParams = new DSAPublicKeyParameters(
			pubKey.getY(), new DSAParameters(params.getP(), params.getQ(),
					params.getG()));
	init(false, bcParams);
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:15,代码来源:DSASignature.java

示例9: fromJavaKey

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public static SigningPublicKey fromJavaKey(DSAPublicKey pk)
                          throws GeneralSecurityException {
    BigInteger y = pk.getY();
    SigType type = SigType.DSA_SHA1;
    int len = type.getPubkeyLen();
    byte[] by = rectify(y, len);
    return new SigningPublicKey(type, by);
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:9,代码来源:SigUtil.java

示例10: getNextWorkingKey

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/**
 * Return the next working key inheriting DSA parameters if necessary.
 * <p>
 * This methods inherits DSA parameters from the indexed certificate or
 * previous certificates in the certificate chain to the returned
 * <code>PublicKey</code>. The list is searched upwards, meaning the end
 * certificate is at position 0 and previous certificates are following.
 * </p>
 * <p>
 * If the indexed certificate does not contain a DSA key this method simply
 * returns the public key. If the DSA key already contains DSA parameters
 * the key is also only returned.
 * </p>
 *
 * @param certs The certification path.
 * @param index The index of the certificate which contains the public key
 *              which should be extended with DSA parameters.
 * @return The public key of the certificate in list position
 *         <code>index</code> extended with DSA parameters if applicable.
 * @throws AnnotatedException if DSA parameters cannot be inherited.
 */
protected static PublicKey getNextWorkingKey(List certs, int index)
    throws CertPathValidatorException
{
    Certificate cert = (Certificate)certs.get(index);
    PublicKey pubKey = cert.getPublicKey();
    if (!(pubKey instanceof DSAPublicKey))
    {
        return pubKey;
    }
    DSAPublicKey dsaPubKey = (DSAPublicKey)pubKey;
    if (dsaPubKey.getParams() != null)
    {
        return dsaPubKey;
    }
    for (int i = index + 1; i < certs.size(); i++)
    {
        X509Certificate parentCert = (X509Certificate)certs.get(i);
        pubKey = parentCert.getPublicKey();
        if (!(pubKey instanceof DSAPublicKey))
        {
            throw new CertPathValidatorException(
                "DSA parameters cannot be inherited from previous certificate.");
        }
        DSAPublicKey prevDSAPubKey = (DSAPublicKey)pubKey;
        if (prevDSAPubKey.getParams() == null)
        {
            continue;
        }
        DSAParams dsaParams = prevDSAPubKey.getParams();
        DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(
            dsaPubKey.getY(), dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
        try
        {
            KeyFactory keyFactory = KeyFactory.getInstance("DSA", BouncyCastleProvider.PROVIDER_NAME);
            return keyFactory.generatePublic(dsaPubKeySpec);
        }
        catch (Exception exception)
        {
            throw new RuntimeException(exception.getMessage());
        }
    }
    throw new CertPathValidatorException("DSA parameters cannot be inherited from previous certificate.");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:65,代码来源:CertPathValidatorUtilities.java

示例11: JDKDSAPublicKey

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
JDKDSAPublicKey(
    DSAPublicKey    key)
{
    this.y = key.getY();
    this.dsaSpec = key.getParams();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JDKDSAPublicKey.java

示例12: BCDSAPublicKey

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
BCDSAPublicKey(
    DSAPublicKey key)
{
    this.y = key.getY();
    this.dsaSpec = key.getParams();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:BCDSAPublicKey.java

示例13: getNextWorkingKey

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/**
 * Return the next working key inheriting DSA parameters if necessary.
 * <p>
 * This methods inherits DSA parameters from the indexed certificate or
 * previous certificates in the certificate chain to the returned
 * <code>PublicKey</code>. The list is searched upwards, meaning the end
 * certificate is at position 0 and previous certificates are following.
 * </p>
 * <p>
 * If the indexed certificate does not contain a DSA key this method simply
 * returns the public key. If the DSA key already contains DSA parameters
 * the key is also only returned.
 * </p>
 *
 * @param certs The certification path.
 * @param index The index of the certificate which contains the public key
 *              which should be extended with DSA parameters.
 * @return The public key of the certificate in list position
 *         <code>index</code> extended with DSA parameters if applicable.
 * @throws AnnotatedException if DSA parameters cannot be inherited.
 */
protected static PublicKey getNextWorkingKey(List certs, int index, JcaJceHelper helper)
    throws CertPathValidatorException
{
    Certificate cert = (Certificate)certs.get(index);
    PublicKey pubKey = cert.getPublicKey();
    if (!(pubKey instanceof DSAPublicKey))
    {
        return pubKey;
    }
    DSAPublicKey dsaPubKey = (DSAPublicKey)pubKey;
    if (dsaPubKey.getParams() != null)
    {
        return dsaPubKey;
    }
    for (int i = index + 1; i < certs.size(); i++)
    {
        X509Certificate parentCert = (X509Certificate)certs.get(i);
        pubKey = parentCert.getPublicKey();
        if (!(pubKey instanceof DSAPublicKey))
        {
            throw new CertPathValidatorException(
                "DSA parameters cannot be inherited from previous certificate.");
        }
        DSAPublicKey prevDSAPubKey = (DSAPublicKey)pubKey;
        if (prevDSAPubKey.getParams() == null)
        {
            continue;
        }
        DSAParams dsaParams = prevDSAPubKey.getParams();
        DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(
            dsaPubKey.getY(), dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
        try
        {
            KeyFactory keyFactory = helper.createKeyFactory("DSA");
            return keyFactory.generatePublic(dsaPubKeySpec);
        }
        catch (Exception exception)
        {
            throw new RuntimeException(exception.getMessage());
        }
    }
    throw new CertPathValidatorException("DSA parameters cannot be inherited from previous certificate.");
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:65,代码来源:CertPathValidatorUtilities.java

示例14: encodeDsaPublicKeyAsBitString

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
private byte[] encodeDsaPublicKeyAsBitString(DSAPublicKey dsaPublicKey) throws IOException {
	ASN1Integer publicKey = new ASN1Integer(dsaPublicKey.getY());

	return publicKey.getEncoded(ASN1Encoding.DER);
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:6,代码来源:KeyIdentifierGenerator.java

示例15: testNONEwithDSA

import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
private void testNONEwithDSA()
    throws Exception
{
    byte[] dummySha1 = Hex.decode("01020304050607080910111213141516");

    KeyPairGenerator kpGen = KeyPairGenerator.getInstance("DSA", "BC");

    kpGen.initialize(512);

    KeyPair          kp = kpGen.generateKeyPair();

    Signature        sig = Signature.getInstance("NONEwithDSA", "BC");

    sig.initSign(kp.getPrivate());

    sig.update(dummySha1);

    byte[] sigBytes = sig.sign();

    sig.initVerify(kp.getPublic());

    sig.update(dummySha1);

    sig.verify(sigBytes);

    // reset test

    sig.update(dummySha1);

    if (!sig.verify(sigBytes))
    {
        fail("NONEwithDSA failed to reset");
    }

    // lightweight test
    DSAPublicKey  key = (DSAPublicKey)kp.getPublic();
    DSAParameters params = new DSAParameters(key.getParams().getP(), key.getParams().getQ(), key.getParams().getG());
    DSAPublicKeyParameters keyParams = new DSAPublicKeyParameters(key.getY(), params);
    DSASigner signer = new DSASigner();
    ASN1Sequence derSig = ASN1Sequence.getInstance(ASN1Primitive.fromByteArray(sigBytes));

    signer.init(false, keyParams);

    if (!signer.verifySignature(dummySha1, DERInteger.getInstance(derSig.getObjectAt(0)).getValue(), DERInteger.getInstance(derSig.getObjectAt(1)).getValue()))
    {
        fail("NONEwithDSA not really NONE!");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:49,代码来源:DSATest.java


注:本文中的java.security.interfaces.DSAPublicKey.getY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。