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


Java NISTObjectIdentifiers.id_sha256方法代码示例

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


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

示例1: getOIDForHashAlgorithm

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public static ASN1ObjectIdentifier getOIDForHashAlgorithm(int hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return PKCSObjectIdentifiers.md5;
    case HashAlgorithm.sha1:
        return X509ObjectIdentifiers.id_SHA1;
    case HashAlgorithm.sha224:
        return NISTObjectIdentifiers.id_sha224;
    case HashAlgorithm.sha256:
        return NISTObjectIdentifiers.id_sha256;
    case HashAlgorithm.sha384:
        return NISTObjectIdentifiers.id_sha384;
    case HashAlgorithm.sha512:
        return NISTObjectIdentifiers.id_sha512;
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:TlsUtils.java

示例2: getOIDForHashAlgorithm

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public static ASN1ObjectIdentifier getOIDForHashAlgorithm(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return PKCSObjectIdentifiers.md5;
    case HashAlgorithm.sha1:
        return X509ObjectIdentifiers.id_SHA1;
    case HashAlgorithm.sha224:
        return NISTObjectIdentifiers.id_sha224;
    case HashAlgorithm.sha256:
        return NISTObjectIdentifiers.id_sha256;
    case HashAlgorithm.sha384:
        return NISTObjectIdentifiers.id_sha384;
    case HashAlgorithm.sha512:
        return NISTObjectIdentifiers.id_sha512;
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:21,代码来源:TlsUtils.java

示例3: getValue

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
@Override
	public Attribute getValue() throws SignerException {
		try {
			X509Certificate cert = (X509Certificate) certificates[0];
			X509Certificate issuerCert = (X509Certificate) certificates[1];
			Digest digest = DigestFactory.getInstance().factoryDefault();
			digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
			byte[] certHash = digest.digest(cert.getEncoded());
			X500Name dirName = new X500Name(issuerCert.getSubjectX500Principal().getName());
			GeneralName name = new GeneralName(dirName);
			GeneralNames issuer = new GeneralNames(name);
			ASN1Integer serialNumber = new ASN1Integer(cert.getSerialNumber());
			IssuerSerial issuerSerial = new IssuerSerial(issuer, serialNumber);
			AlgorithmIdentifier algId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256);// SHA-256
			ESSCertIDv2 essCertIDv2 = new ESSCertIDv2(algId, certHash, issuerSerial);
//			return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(essCertIDv2)));
			return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(
					new ASN1Encodable[] { new DERSequence(essCertIDv2) })));
		} catch (CertificateEncodingException ex) {
			throw new SignerException(ex.getMessage());
		}
	}
 
开发者ID:demoiselle,项目名称:signer,代码行数:23,代码来源:SigningCertificateV2.java

示例4: performTest

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public void performTest()
    throws Exception
{
    // check getInstance on default algorithm.
    byte[] digest = new byte [256];
    ESSCertIDv2 essCertIdv2 = new ESSCertIDv2(new AlgorithmIdentifier(
        NISTObjectIdentifiers.id_sha256), digest);
    ASN1Primitive asn1Object = essCertIdv2.toASN1Primitive();

    ESSCertIDv2.getInstance(asn1Object);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:12,代码来源:ESSCertIDv2UnitTest.java

示例5: getValue

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
@Override
  public Attribute getValue() throws SignerException {
  	
  	try {
  		int chainSize = certificates.length -1;
  		OtherCertID[] arrayOtherCertID = new OtherCertID[chainSize];	
  		  for (int i = 1; i <= chainSize; i++ ){
  			  	X509Certificate issuerCert = null;
  		  	    X509Certificate cert = (X509Certificate) certificates[i];
  		  	    if (i < chainSize){  
  		  	    	issuerCert = (X509Certificate) certificates[i+1];
  		  	    }else{ // raiz
  		  	    	issuerCert = (X509Certificate) certificates[i];
  		  	    }
  	    		Digest digest = DigestFactory.getInstance().factoryDefault();
  	    		digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
  				byte[] certHash = digest.digest(cert.getEncoded());
  				X500Name dirName = new X500Name(issuerCert.getSubjectX500Principal().getName());
  				GeneralName name = new GeneralName(dirName);
  				GeneralNames issuer = new GeneralNames(name);
  				ASN1Integer serialNumber = new ASN1Integer(cert.getSerialNumber());
  				IssuerSerial issuerSerial = new IssuerSerial(issuer, serialNumber);
  				AlgorithmIdentifier algId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256);
  				OtherCertID otherCertID = new OtherCertID(algId, certHash, issuerSerial);
  				arrayOtherCertID[i -1] = otherCertID; 
  		 }	 
  		
	return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new ASN1Encodable[] { new DERSequence(arrayOtherCertID) }));
  	} catch (CertificateEncodingException e) {
  		throw new SignerException(e.getMessage());
}        
  }
 
开发者ID:demoiselle,项目名称:signer,代码行数:33,代码来源:CertificateRefs.java

示例6: JceKTSKeyWrapper

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public JceKTSKeyWrapper(PublicKey publicKey, String symmetricWrappingAlg, int keySizeInBits, byte[] partyUInfo, byte[] partyVInfo)
{
    super(new AlgorithmIdentifier(PKCSObjectIdentifiers.id_rsa_KEM, new GenericHybridParameters(new AlgorithmIdentifier(ISOIECObjectIdentifiers.id_kem_rsa, new RsaKemParameters(new AlgorithmIdentifier(X9ObjectIdentifiers.id_kdf_kdf3, new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256)), (keySizeInBits + 7) / 8)), JceSymmetricKeyWrapper.determineKeyEncAlg(symmetricWrappingAlg, keySizeInBits))));

    this.publicKey = publicKey;
    this.symmetricWrappingAlg = symmetricWrappingAlg;
    this.keySizeInBits = keySizeInBits;
    this.partyUInfo = Arrays.clone(partyUInfo);
    this.partyVInfo = Arrays.clone(partyVInfo);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:11,代码来源:JceKTSKeyWrapper.java

示例7: Builder

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
/**
 * Basic builder.
 *
 * @param algorithmName the algorithm name for the secret key we use for wrapping.
 * @param keySizeInBits the size of the wrapping key we want to produce in bits.
 * @param otherInfo     the otherInfo/IV encoding to be applied to the KDF.
 */
public Builder(String algorithmName, int keySizeInBits, byte[] otherInfo)
{
    this.algorithmName = algorithmName;
    this.keySizeInBits = keySizeInBits;
    this.kdfAlgorithm = new AlgorithmIdentifier(X9ObjectIdentifiers.id_kdf_kdf3, new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256));
    this.otherInfo = (otherInfo == null) ? new byte[0] : Arrays.clone(otherInfo);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:15,代码来源:KTSParameterSpec.java

示例8: digestInfoSha256

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
@Test
public void digestInfoSha256() throws Exception {
	byte[] message = "hello world".getBytes();
	MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
	byte[] digest = messageDigest.digest(message);
	LOG.debug("Digest: " + new String(Hex.encodeHex(digest)));
	DERObjectIdentifier hashAlgoId = NISTObjectIdentifiers.id_sha256;
	DigestInfo digestInfo = new DigestInfo(new AlgorithmIdentifier(hashAlgoId, DERNull.INSTANCE), digest);
	byte[] encodedDigestInfo = digestInfo.getEncoded();
	LOG.debug("Digest Info: " + new String(Hex.encodeHex(encodedDigestInfo)));
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:12,代码来源:DerTest.java

示例9: testAsGreenhandUpdated

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/33305800/difference-between-sha256withrsa-and-sha256-then-rsa">
 * Difference between SHA256withRSA and SHA256 then RSA
 * </a>
 * <p>
 * This method is the updated code provided by the OP. As expected it shows two equal signatures.
 * The OP's observations seem to differ, though.
 * </p>
 */
public void testAsGreenhandUpdated(PrivateKey privateKey) throws GeneralSecurityException, IOException
{
    System.out.println("\nGreenhandUpdated:");

    String s = "1234";
    MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
    messageDigest.update(s.getBytes());
    byte[] outputDigest = messageDigest.digest();

    AlgorithmIdentifier sha256Aid = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE);
    DigestInfo di = new DigestInfo(sha256Aid, outputDigest);
    //sign SHA256 with RSA
    Signature rsaSignature = Signature.getInstance("RSA");
    rsaSignature.initSign(privateKey);
    byte[] encodedDigestInfo = di.toASN1Primitive().getEncoded();
    rsaSignature.update(encodedDigestInfo);
    byte[] signed = rsaSignature.sign();
    System.out.println("method 1: "+bytesToHex(signed));
    System.out.println("    hash: " + bytesToHex(outputDigest));
    System.out.println("    algo: " + sha256Aid.getAlgorithm());
    System.out.println("    info: " + bytesToHex(encodedDigestInfo));

    //compute SHA256withRSA as a single step
    Signature rsaSha256Signature = Signature.getInstance("SHA256withRSA");
    rsaSha256Signature.initSign(privateKey);
    rsaSha256Signature.update(s.getBytes());
    byte[] signed2 = rsaSha256Signature.sign();
    System.out.println("method 2: "+bytesToHex(signed2));
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:39,代码来源:SignInSteps.java

示例10: SHA256

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public SHA256()
{
    super(NISTObjectIdentifiers.id_sha256, new SHA256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DigestSignatureSpi.java

示例11: SHA256

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public SHA256()
{
    super(NISTObjectIdentifiers.id_sha256, new SHA256Digest(), new PKCS1Encoding(new NativeRSAEngine()));
}
 
开发者ID:lookout,项目名称:fast-rsa-engine,代码行数:5,代码来源:FastDigestSignatureSpi.java

示例12: SHA256

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
/**
 * Creates a new instance configured with the default configuration.
 */
public SHA256() {
    super(NISTObjectIdentifiers.id_sha256,
          getDigest("SHA-256"),
          new PKCS1Encoding(new NativeRSABlindedEngine()));
}
 
开发者ID:joyent,项目名称:java-http-signature,代码行数:9,代码来源:NativeRSAWithSHA.java

示例13: SHA256WithRSAEncryption

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public SHA256WithRSAEncryption()
{
    super(NISTObjectIdentifiers.id_sha256, new SHA256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
}
 
开发者ID:StefanoSalsano,项目名称:alien-ofelia-conet-ccnx,代码行数:5,代码来源:JDKDigestSignature.java

示例14: testGenerateWithMetadataAndDifferentAlgorithmIdentifier

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public void testGenerateWithMetadataAndDifferentAlgorithmIdentifier()
    throws Exception
{
    cmsTimeStampedDataGenerator.setMetaData(true, fileInput, "TXT");

    BcDigestCalculatorProvider calculatorProvider = new BcDigestCalculatorProvider();

    ASN1ObjectIdentifier algIdentifier = NISTObjectIdentifiers.id_sha224;

    DigestCalculator hashCalculator = calculatorProvider.get(new AlgorithmIdentifier(algIdentifier));
    cmsTimeStampedDataGenerator.initialiseMessageImprintDigestCalculator(hashCalculator);
    hashCalculator.getOutputStream().write(baseData);
    hashCalculator.getOutputStream().close();

    byte[] requestData = hashCalculator.getDigest();
    TimeStampToken timeStampToken = createTimeStampToken(requestData, algIdentifier);

    CMSTimeStampedData cmsTimeStampedData = cmsTimeStampedDataGenerator.generate(timeStampToken, baseData);

    for (int i = 0; i < 3; i++) {
        switch (i) {
        case 0:
            algIdentifier =    NISTObjectIdentifiers.id_sha224;
            break;
        case 1:
            algIdentifier =    NISTObjectIdentifiers.id_sha256;
            break;
        case 2:
            algIdentifier =    NISTObjectIdentifiers.id_sha384;
            break;
        case 3:
            algIdentifier =    NISTObjectIdentifiers.id_sha512;
            break;
        }
        hashCalculator = calculatorProvider.get(new AlgorithmIdentifier(algIdentifier));
        byte[] newRequestData = cmsTimeStampedData.calculateNextHash(hashCalculator);
        TimeStampToken newTimeStampToken = createTimeStampToken(newRequestData, algIdentifier);
        cmsTimeStampedData = cmsTimeStampedData.addTimeStamp(newTimeStampToken);
    }
    byte[] timeStampedData = cmsTimeStampedData.getEncoded();

    metadataCheck(timeStampedData);
    metadataParserCheck(timeStampedData);

}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:46,代码来源:CMSTimeStampedDataGeneratorTest.java

示例15: getAlgorithmIdentifier

import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; //导入方法依赖的package包/类
public AlgorithmIdentifier getAlgorithmIdentifier()
{
    return new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:5,代码来源:SHA256DigestCalculator.java


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