本文整理汇总了Java中org.bouncycastle.bcpg.PublicKeyPacket类的典型用法代码示例。如果您正苦于以下问题:Java PublicKeyPacket类的具体用法?Java PublicKeyPacket怎么用?Java PublicKeyPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PublicKeyPacket类属于org.bouncycastle.bcpg包,在下文中一共展示了PublicKeyPacket类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAgreementAlgorithm
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
public static String getAgreementAlgorithm(PublicKeyPacket pubKeyData)
{
ECDHPublicBCPGKey ecKey = (ECDHPublicBCPGKey)pubKeyData.getKey();
switch (ecKey.getHashAlgorithm())
{
case HashAlgorithmTags.SHA256:
return "ECCDHwithSHA256CKDF";
case HashAlgorithmTags.SHA384:
return "ECCDHwithSHA384CKDF";
case HashAlgorithmTags.SHA512:
return "ECCDHwithSHA512CKDF";
default:
throw new IllegalArgumentException("Unknown hash algorithm specified: " + ecKey.getHashAlgorithm());
}
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:17,代码来源:RFC6637Utils.java
示例2: createUserKeyingMaterial
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
public static byte[] createUserKeyingMaterial(PublicKeyPacket pubKeyData, KeyFingerPrintCalculator fingerPrintCalculator)
throws IOException, PGPException
{
ByteArrayOutputStream pOut = new ByteArrayOutputStream();
ECDHPublicBCPGKey ecKey = (ECDHPublicBCPGKey)pubKeyData.getKey();
byte[] encOid = ecKey.getCurveOID().getEncoded();
pOut.write(encOid, 1, encOid.length - 1);
pOut.write(pubKeyData.getAlgorithm());
pOut.write(0x03);
pOut.write(0x01);
pOut.write(ecKey.getHashAlgorithm());
pOut.write(ecKey.getSymmetricKeyAlgorithm());
pOut.write(ANONYMOUS_SENDER);
pOut.write(fingerPrintCalculator.calculateFingerprint(pubKeyData));
return pOut.toByteArray();
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:19,代码来源:RFC6637Utils.java
示例3: PGPPublicKey
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
PGPPublicKey(
PublicKeyPacket publicPk,
TrustPacket trustPk,
List keySigs,
List ids,
List idTrusts,
List idSigs,
KeyFingerPrintCalculator fingerPrintCalculator)
throws PGPException
{
this.publicPk = publicPk;
this.trustPk = trustPk;
this.keySigs = keySigs;
this.ids = ids;
this.idTrusts = idTrusts;
this.idSigs = idSigs;
init(fingerPrintCalculator);
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:20,代码来源:PGPPublicKey.java
示例4: mockPrivateKey
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
private static PGPPrivateKey mockPrivateKey(
boolean altId,
boolean altBcpgKeyFormat,
boolean altBcpgKeyEncoded,
boolean altPublicKeyPacketEncoded)
throws IOException {
String bcpgKeyFormat = altBcpgKeyFormat ? "alternate" : "bcpgFormat";
String bcpgKeyEncoded = altBcpgKeyEncoded ? "alternate" : "bcpgEncoded";
String publicKeyPacketEncoded = altPublicKeyPacketEncoded ? "alternate" : "packetEncoded";
BCPGKey bcpgKey = mock(BCPGKey.class);
PublicKeyPacket publicKeyPacket = mock(PublicKeyPacket.class);
when(bcpgKey.getFormat()).thenReturn(bcpgKeyFormat);
when(bcpgKey.getEncoded()).thenReturn(bcpgKeyEncoded.getBytes(UTF_8));
when(publicKeyPacket.getEncoded()).thenReturn(publicKeyPacketEncoded.getBytes(UTF_8));
return new PGPPrivateKey(altId ? 2 : 1, publicKeyPacket, bcpgKey);
}
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:ComparatorKeyringTest.java
示例5: PGPPrivateKey
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
public PGPPrivateKey(
long keyID,
PublicKeyPacket publicKeyPacket,
BCPGKey privateKeyDataPacket)
{
this.keyID = keyID;
this.publicKeyPacket = publicKeyPacket;
this.privateKeyDataPacket = privateKeyDataPacket;
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:10,代码来源:PGPPrivateKey.java
示例6: readSubkey
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
static PGPPublicKey readSubkey(BCPGInputStream in, KeyFingerPrintCalculator fingerPrintCalculator)
throws IOException, PGPException
{
PublicKeyPacket pk = (PublicKeyPacket)in.readPacket();
TrustPacket kTrust = readOptionalTrustPacket(in);
// PGP 8 actually leaves out the signature.
List sigList = readSignaturesAndTrust(in);
return new PGPPublicKey(pk, kTrust, sigList, fingerPrintCalculator);
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:12,代码来源:PGPPublicKeyRing.java
示例7: compare
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
@VisibleForTesting
static boolean compare(PublicKeyPacket a, PublicKeyPacket b) {
if (a == null || b == null) {
return a == null && b == null;
}
try {
return Arrays.equals(a.getEncoded(), b.getEncoded());
} catch (IOException e) {
logger.severefmt("ComparatorKeyring error: PublicKeyPacket.getEncoded failed: %s", e);
return false;
}
}
开发者ID:google,项目名称:nomulus,代码行数:13,代码来源:ComparatorKeyring.java
示例8: printPublicKey
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
@Override
public void printPublicKey ( final OutputStream out ) throws IOException
{
final ArmoredOutputStream armoredOutput = new ArmoredOutputStream ( out );
final PublicKeyPacket pubKey = this.privateKey.getPublicKeyPacket ();
pubKey.encode ( new BCPGOutputStream ( armoredOutput ) );
armoredOutput.close ();
}
开发者ID:ctron,项目名称:package-drone,代码行数:9,代码来源:PgpSigningService.java
示例9: getPublicKeyPacket
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
public PublicKeyPacket getPublicKeyPacket()
{
return publicKeyPacket;
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:5,代码来源:PGPPrivateKey.java
示例10: parseSecretKeyFromSExpr
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
/**
* Parse a secret key from one of the GPG S expression keys.
*
* @return a secret key object.
*/
public static PGPSecretKey parseSecretKeyFromSExpr(InputStream inputStream, PBEProtectionRemoverFactory keyProtectionRemoverFactory, KeyFingerPrintCalculator fingerPrintCalculator)
throws IOException, PGPException
{
SXprUtils.skipOpenParenthesis(inputStream);
String type;
type = SXprUtils.readString(inputStream, inputStream.read());
if (type.equals("protected-private-key"))
{
SXprUtils.skipOpenParenthesis(inputStream);
String curveName;
String keyType = SXprUtils.readString(inputStream, inputStream.read());
if (keyType.equals("ecc"))
{
SXprUtils.skipOpenParenthesis(inputStream);
String curveID = SXprUtils.readString(inputStream, inputStream.read());
curveName = SXprUtils.readString(inputStream, inputStream.read());
if (curveName.startsWith("NIST "))
{
curveName = curveName.substring("NIST ".length());
}
SXprUtils.skipCloseParenthesis(inputStream);
}
else
{
throw new PGPException("no curve details found");
}
byte[] qVal;
SXprUtils.skipOpenParenthesis(inputStream);
type = SXprUtils.readString(inputStream, inputStream.read());
if (type.equals("q"))
{
qVal = SXprUtils.readBytes(inputStream, inputStream.read());
}
else
{
throw new PGPException("no q value found");
}
PublicKeyPacket pubPacket = new PublicKeyPacket(PublicKeyAlgorithmTags.ECDSA, new Date(), new ECDSAPublicBCPGKey(ECNamedCurveTable.getOID(curveName), new BigInteger(1, qVal)));
SXprUtils.skipCloseParenthesis(inputStream);
byte[] dValue = getDValue(inputStream, keyProtectionRemoverFactory, curveName);
// TODO: check SHA-1 hash.
return new PGPSecretKey(new SecretKeyPacket(pubPacket, SymmetricKeyAlgorithmTags.NULL, null, null, new ECSecretBCPGKey(new BigInteger(1, dValue)).getEncoded()), new PGPPublicKey(pubPacket, fingerPrintCalculator));
}
throw new PGPException("unknown key type found");
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:66,代码来源:PGPSecretKey.java
示例11: calculateFingerprint
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
byte[] calculateFingerprint(PublicKeyPacket publicPk)
throws PGPException;
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:3,代码来源:KeyFingerPrintCalculator.java
示例12: getPublicKeyPacket
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
public PublicKeyPacket getPublicKeyPacket()
{
return publicPk;
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:5,代码来源:PGPPublicKey.java
示例13: PGPPublicKeyRing
import org.bouncycastle.bcpg.PublicKeyPacket; //导入依赖的package包/类
public PGPPublicKeyRing(
InputStream in,
KeyFingerPrintCalculator fingerPrintCalculator)
throws IOException
{
this.keys = new ArrayList();
BCPGInputStream pIn = wrap(in);
int initialTag = pIn.nextPacketTag();
if (initialTag != PacketTags.PUBLIC_KEY && initialTag != PacketTags.PUBLIC_SUBKEY)
{
throw new IOException(
"public key ring doesn't start with public key tag: " +
"tag 0x" + Integer.toHexString(initialTag));
}
PublicKeyPacket pubPk = (PublicKeyPacket)pIn.readPacket();
TrustPacket trustPk = readOptionalTrustPacket(pIn);
// direct signatures and revocations
List keySigs = readSignaturesAndTrust(pIn);
List ids = new ArrayList();
List idTrusts = new ArrayList();
List idSigs = new ArrayList();
readUserIDs(pIn, ids, idTrusts, idSigs);
try
{
keys.add(new PGPPublicKey(pubPk, trustPk, keySigs, ids, idTrusts, idSigs, fingerPrintCalculator));
// Read subkeys
while (pIn.nextPacketTag() == PacketTags.PUBLIC_SUBKEY)
{
keys.add(readSubkey(pIn, fingerPrintCalculator));
}
}
catch (PGPException e)
{
throw new IOException("processing exception: " + e.toString());
}
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:44,代码来源:PGPPublicKeyRing.java
注:本文中的org.bouncycastle.bcpg.PublicKeyPacket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论