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


Java DERNull.INSTANCE属性代码示例

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


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

示例1: getAlgorithmIdentifier

protected AlgorithmIdentifier getAlgorithmIdentifier(String encryptionOID, AlgorithmParameters params) throws IOException
{
    ASN1Encodable asn1Params;
    if (params != null)
    {
        asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
    }
    else
    {
        asn1Params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(
        new ASN1ObjectIdentifier(encryptionOID),
        asn1Params);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:CMSEnvelopedGenerator.java

示例2: engineGetEncoded

/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));
    
    return pssP.getEncoded("DER");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:AlgorithmParametersSpi.java

示例3: extractDigesetAlgFromSigAlg

public static AlgorithmIdentifier extractDigesetAlgFromSigAlg( AlgorithmIdentifier sigAlgId)
        throws NoSuchAlgorithmException {
    ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();

    ASN1ObjectIdentifier digestAlgOid;
    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
        ASN1Encodable asn1Encodable = sigAlgId.getParameters();
        RSASSAPSSparams param = RSASSAPSSparams.getInstance(asn1Encodable);
        digestAlgOid = param.getHashAlgorithm().getAlgorithm();
    } else {
        HashAlgoType digestAlg = sigAlgOidToDigestMap.get(algOid);
        if (digestAlg == null) {
            throw new NoSuchAlgorithmException("unknown signature algorithm " + algOid.getId());
        }
        digestAlgOid = digestAlg.oid();
    }

    return new AlgorithmIdentifier(digestAlgOid, DERNull.INSTANCE);
}
 
开发者ID:xipki,项目名称:xitk,代码行数:19,代码来源:AlgorithmUtil.java

示例4: getAlgorithmIdentifier

AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier encryptionOID, AlgorithmParameters params)
    throws CMSException
{
    ASN1Encodable asn1Params;
    if (params != null)
    {
        try
        {
            asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
        }
        catch (IOException e)
        {
            throw new CMSException("cannot encode parameters: " + e.getMessage(), e);
        }
    }
    else
    {
        asn1Params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(
        encryptionOID,
        asn1Params);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:EnvelopedDataHelper.java

示例5: ProofOfPossession

private ProofOfPossession(ASN1TaggedObject tagged)
{
    tagNo = tagged.getTagNo();
    switch (tagNo)
    {
    case 0:
        obj = DERNull.INSTANCE;
        break;
    case 1:
        obj = POPOSigningKey.getInstance(tagged, false);
        break;
    case 2:
    case 3:
        obj = POPOPrivKey.getInstance(tagged, true);
        break;
    default:
        throw new IllegalArgumentException("unknown tag: " + tagNo);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:ProofOfPossession.java

示例6: CertStatus

public CertStatus(
    ASN1TaggedObject    choice)
{
    this.tagNo = choice.getTagNo();

    switch (choice.getTagNo())
    {
    case 0:
        value = DERNull.INSTANCE;
        break;
    case 1:
        value = RevokedInfo.getInstance(choice, false);
        break;
    case 2:
        value = DERNull.INSTANCE;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:CertStatus.java

示例7: getAlgorithmIdentifier

AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier encryptionOID, AlgorithmParameters params)
    throws CMSException
{
    ASN1Encodable asn1Params;
    if (params != null)
    {
        asn1Params = CMSUtils.extractParameters(params);
    }
    else
    {
        asn1Params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(
        encryptionOID,
        asn1Params);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:17,代码来源:EnvelopedDataHelper.java

示例8: getEncoded

/**
 * Return the keyData to encode in the SubjectPublicKeyInfo structure.
 * <p>
 * The ASN.1 definition of the key structure is
 * <pre>
 *       McEliecePublicKey ::= SEQUENCE {
 *         n           Integer      -- length of the code
 *         t           Integer      -- error correcting capability
 *         matrixG     OctetString  -- generator matrix as octet string
 *       }
 * </pre>
 * </p>
 * @return the keyData to encode in the SubjectPublicKeyInfo structure
 */
public byte[] getEncoded()
{
    McElieceCCA2PublicKey key = new McElieceCCA2PublicKey(new ASN1ObjectIdentifier(oid), n, t, g);
    AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(this.getOID(), DERNull.INSTANCE);

    try
    {
        SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key);

        return subjectPublicKeyInfo.getEncoded();
    }
    catch (IOException e)
    {
        return null;
    }

}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:31,代码来源:BCMcElieceCCA2PublicKey.java

示例9: makeV1Certificate

public static X509CertificateHolder makeV1Certificate(AsymmetricCipherKeyPair subKP, String _subDN, AsymmetricCipherKeyPair issKP, String _issDN)
    throws IOException, OperatorCreationException
{
    RSAKeyParameters lwPubKey = (RSAKeyParameters)subKP.getPublic();

    X509v1CertificateBuilder v1CertGen = new X509v1CertificateBuilder(
        new X500Name(_issDN),
        allocateSerialNumber(),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()))
    );

    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1WithRSAEncryption");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build((AsymmetricKeyParameter)issKP.getPrivate());


    return v1CertGen.build(sigGen);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:22,代码来源:CMSTestUtil.java

示例10: encodePublicKey

/**
 * Encode (serialise) a public key in order to store it or transport it over a network.
 * @param publicKey the public key to be encoded; must not be <code>null</code>.
 * @return the encoded (serialised) form of the public key. Can be passed to {@link #decodePublicKey(byte[])} to
 * reverse this method.
 * @see #decodePublicKey(byte[])
 * @see #encodePrivateKey(CipherParameters)
 */
public byte[] encodePublicKey(final CipherParameters publicKey)
{
	if (publicKey == null)
		throw new IllegalArgumentException("publicKey == null");

	// TODO use a class-based map or similar registry!
	try {
		if (publicKey instanceof RSAKeyParameters) {
			final RSAKeyParameters rsaPublicKey = (RSAKeyParameters) publicKey;

			final SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
					new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE),
					new RSAPublicKey(rsaPublicKey.getModulus(), rsaPublicKey.getExponent()).toASN1Primitive()
					);
			return info.getEncoded();
		}
	} catch (final IOException x) {
		throw new RuntimeException(x);
	}

	throw new UnsupportedOperationException("publicKey.class=\"" + publicKey.getClass().getName() + "\" not yet supported!");
}
 
开发者ID:subshare,项目名称:subshare,代码行数:30,代码来源:CryptoRegistry.java

示例11: encodePrivateKey

/**
 * <p>
 * Encode (serialise) a private key in order to store it or transport it over a network.
 * </p><p>
 * <b>Important: You should keep your private key secret!</b> Thus, you might want to encrypt the result before
 * storing it to a file or sending it somewhere!
 * </p>
 * @param privateKey the private key to be encoded; must not be <code>null</code>.
 * @return the encoded (serialised) form of the private key. Can be passed to {@link #decodePrivateKey(byte[])} to
 * reverse this method.
 * @see #decodePrivateKey(byte[])
 * @see #encodePublicKey(CipherParameters)
 */
public byte[] encodePrivateKey(final CipherParameters privateKey)
{
	if (privateKey == null)
		throw new IllegalArgumentException("privateKey == null");

	// TODO use a class-based map or similar registry!
	try {
		if (privateKey instanceof RSAPrivateCrtKeyParameters) {
			final RSAPrivateCrtKeyParameters rsaPrivateKey = (RSAPrivateCrtKeyParameters) privateKey;

			final PrivateKeyInfo info = new PrivateKeyInfo(
					new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE),
					new RSAPrivateKey(
							rsaPrivateKey.getModulus(), rsaPrivateKey.getPublicExponent(), rsaPrivateKey.getExponent(),
							rsaPrivateKey.getP(), rsaPrivateKey.getQ(), rsaPrivateKey.getDP(),
							rsaPrivateKey.getDQ(), rsaPrivateKey.getQInv()).toASN1Primitive()
					);
			return info.getEncoded();
		}
	} catch (final IOException x) {
		throw new RuntimeException(x);
	}

	throw new UnsupportedOperationException("privateKey.class=\"" + privateKey.getClass().getName() + "\" not yet supported!");
}
 
开发者ID:subshare,项目名称:subshare,代码行数:38,代码来源:CryptoRegistry.java

示例12: getSigAlgID

static AlgorithmIdentifier getSigAlgID(
    DERObjectIdentifier sigOid,
    String              algorithmName)
{
    if (noParams.contains(sigOid))
    {
        return new AlgorithmIdentifier(sigOid);
    }

    algorithmName = Strings.toUpperCase(algorithmName);

    if (params.containsKey(algorithmName))
    {
        return new AlgorithmIdentifier(sigOid, (ASN1Encodable)params.get(algorithmName));
    }
    else
    {
        return new AlgorithmIdentifier(sigOid, DERNull.INSTANCE);
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:20,代码来源:X509Util.java

示例13: getEncoded

/**
 * Return the keyData to encode in the SubjectPublicKeyInfo structure.
 * <p/>
 * The ASN.1 definition of the key structure is
 * <p/>
 * <pre>
 *       McEliecePublicKey ::= SEQUENCE {
 *         n           Integer      -- length of the code
 *         t           Integer      -- error correcting capability
 *         matrixG     OctetString  -- generator matrix as octet string
 *       }
 * </pre>
 *
 * @return the keyData to encode in the SubjectPublicKeyInfo structure
 */
public byte[] getEncoded()
{
    McElieceCCA2PublicKey key = new McElieceCCA2PublicKey(new ASN1ObjectIdentifier(oid), n, t, g);
    AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(this.getOID(), DERNull.INSTANCE);

    try
    {
        SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key);

        return subjectPublicKeyInfo.getEncoded();
    }
    catch (IOException e)
    {
        return null;
    }

}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:32,代码来源:BCMcElieceCCA2PublicKey.java

示例14: getEncoded

/**
 * Return the keyData to encode in the SubjectPublicKeyInfo structure.
 * <p/>
 * The ASN.1 definition of the key structure is
 * <p/>
 * <pre>
 *       McEliecePublicKey ::= SEQUENCE {
 *         n           Integer      -- length of the code
 *         t           Integer      -- error correcting capability
 *         matrixG     OctetString  -- generator matrix as octet string
 *       }
 * </pre>
 *
 * @return the keyData to encode in the SubjectPublicKeyInfo structure
 */
public byte[] getEncoded()
{
    McEliecePublicKey key = new McEliecePublicKey(new ASN1ObjectIdentifier(oid), n, t, g);
    AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(this.getOID(), DERNull.INSTANCE);

    try
    {
        SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key);

        return subjectPublicKeyInfo.getEncoded();
    }
    catch (IOException e)
    {
        return null;
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:31,代码来源:BCMcEliecePublicKey.java

示例15: engineGetEncoded

/**
 * Return the PKCS#1 ASN.1 structure RSAES-OAEP-params.
 */
protected byte[] engineGetEncoded() 
{
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                                    DigestFactory.getOID(currentSpec.getDigestAlgorithm()),
                                                    DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                                    PKCSObjectIdentifiers.id_mgf1,
                                                    new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
    AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier(
                                                    PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
    RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm);
    
    try
    {
        return oaepP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding OAEPParameters");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:26,代码来源:AlgorithmParametersSpi.java


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