本文整理汇总了Java中java.security.interfaces.DSAPublicKey.getParams方法的典型用法代码示例。如果您正苦于以下问题:Java DSAPublicKey.getParams方法的具体用法?Java DSAPublicKey.getParams怎么用?Java DSAPublicKey.getParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.interfaces.DSAPublicKey
的用法示例。
在下文中一共展示了DSAPublicKey.getParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: marshalPublicKey
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
@Override
void marshalPublicKey(XmlWriter xwriter, DSAPublicKey publicKey, String dsPrefix,
XMLCryptoContext context)
throws MarshalException
{
DSAParams params = publicKey.getParams();
xwriter.writeStartElement(dsPrefix, "DSAKeyValue", XMLSignature.XMLNS);
// parameters J, Seed & PgenCounter are not included
writeBase64BigIntegerElement(xwriter, dsPrefix, "P", XMLSignature.XMLNS, params.getP());
writeBase64BigIntegerElement(xwriter, dsPrefix, "Q", XMLSignature.XMLNS, params.getQ());
writeBase64BigIntegerElement(xwriter, dsPrefix, "G", XMLSignature.XMLNS, params.getG());
writeBase64BigIntegerElement(xwriter, dsPrefix, "Y", XMLSignature.XMLNS, publicKey.getY() );
xwriter.writeEndElement(); // "DSAKeyValue"
}
示例2: writePublicKey
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public void writePublicKey(PublicKey pubKey) throws IOException {
if (!(pubKey instanceof DSAPublicKey))
throw new UnsupportedOperationException(
"Key types other than DSA are not supported at the moment.");
DSAPublicKey dsaKey = (DSAPublicKey) pubKey;
writeShort(0);
DSAParams dsaParams = dsaKey.getParams();
writeBigInt(dsaParams.getP());
writeBigInt(dsaParams.getQ());
writeBigInt(dsaParams.getG());
writeBigInt(dsaKey.getY());
}
示例3: writePublicKey
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public void writePublicKey(PublicKey pubKey) throws IOException {
if (!(pubKey instanceof DSAPublicKey))
throw new UnsupportedOperationException(
"Key types other than DSA are not supported at the moment.");
DSAPublicKey dsaKey = (DSAPublicKey) pubKey;
writeShort(0);
DSAParams dsaParams = dsaKey.getParams();
writeBigInt(dsaParams.getP());
writeBigInt(dsaParams.getQ());
writeBigInt(dsaParams.getG());
writeBigInt(dsaKey.getY());
}
示例4: test_initializeLjava_security_spec_AlgorithmParameterSpec
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/**
* @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)
*/
@TestTargetNew(
level = TestLevel.PARTIAL,
notes = "InvalidAlgorithmParameterException checking missed",
method = "initialize",
args = {java.security.spec.AlgorithmParameterSpec.class}
)
public void test_initializeLjava_security_spec_AlgorithmParameterSpec()
throws Exception {
// create DSAParams
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
keyPairGenerator.initialize(1024);
DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
.getPublic();
DSAParams params = key.getParams();
KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
params.getG()));
}
示例5: test_initializeLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/**
* @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec,
* java.security.SecureRandom)
*/
@TestTargetNew(
level = TestLevel.PARTIAL,
notes = "InvalidAlgorithmParameterException checking missed",
method = "initialize",
args = {java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class}
)
public void test_initializeLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom()
throws Exception {
// create DSAParams
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
keyPairGenerator.initialize(1024);
DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
.getPublic();
DSAParams params = key.getParams();
KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
params.getG()), new SecureRandom());
}
示例6: 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());
}
}
示例7: recoverKeyPair_Dsa
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
@Test
public void recoverKeyPair_Dsa() throws Exception {
KeyPair kp = PubkeyUtils.recoverKeyPair(DSA_KEY_PKCS8);
DSAPublicKey pubKey = (DSAPublicKey) kp.getPublic();
assertEquals(DSA_KEY_pub, pubKey.getY());
DSAParams params = pubKey.getParams();
assertEquals(params.getG(), DSA_KEY_G);
assertEquals(params.getP(), DSA_KEY_P);
assertEquals(params.getQ(), DSA_KEY_Q);
}
示例8: 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());
}
示例9: encodeSSHDSAPublicKey
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public static byte[] encodeSSHDSAPublicKey(DSAPublicKey pk) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
DSAParams params = pk.getParams();
tw.writeMPInt(params.getP());
tw.writeMPInt(params.getQ());
tw.writeMPInt(params.getG());
tw.writeMPInt(pk.getY());
return tw.getBytes();
}
示例10: testRecoverKeyPair_Dsa
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public void testRecoverKeyPair_Dsa() throws Exception {
KeyPair kp = PubkeyUtils.recoverKeyPair(DSA_KEY_PKCS8);
DSAPublicKey pubKey = (DSAPublicKey) kp.getPublic();
assertEquals(DSA_KEY_pub, pubKey.getY());
DSAParams params = pubKey.getParams();
assertEquals(params.getG(), DSA_KEY_G);
assertEquals(params.getP(), DSA_KEY_P);
assertEquals(params.getQ(), DSA_KEY_Q);
}
示例11: areEqual
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
private boolean areEqual(DSAPublicKey pk1, DSAPublicKey pk2)
{
if (pk1.getY().compareTo(pk2.getY()) != 0)
return false;
DSAParams p1 = pk1.getParams();
DSAParams p2 = pk2.getParams();
if (p1.getG().compareTo(p2.getG()) != 0)
return false;
if (p1.getP().compareTo(p2.getP()) != 0)
return false;
return p1.getQ().compareTo(p2.getQ()) == 0;
}
示例12: readSignature
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
public byte[] readSignature(PublicKey pubKey) throws IOException {
if (!pubKey.getAlgorithm().equals("DSA"))
throw new UnsupportedOperationException();
DSAPublicKey dsaPubKey = (DSAPublicKey) pubKey;
DSAParams dsaParams = dsaPubKey.getParams();
byte[] sig = new byte[dsaParams.getQ().bitLength() / 4];
read(sig);
return sig;
}
示例13: 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);
}
示例14: test_initializeLjava_security_spec_AlgorithmParameterSpec
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/**
* @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)
*/
public void test_initializeLjava_security_spec_AlgorithmParameterSpec()
throws Exception {
// create DSAParams
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
keyPairGenerator.initialize(1024);
DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
.getPublic();
DSAParams params = key.getParams();
KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
params.getG()));
}
示例15: test_initializeLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom
import java.security.interfaces.DSAPublicKey; //导入方法依赖的package包/类
/**
* @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec,
* java.security.SecureRandom)
*/
public void test_initializeLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom()
throws Exception {
// create DSAParams
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
keyPairGenerator.initialize(1024);
DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
.getPublic();
DSAParams params = key.getParams();
KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
params.getG()), new SecureRandom());
}