List of usage examples for org.bouncycastle.asn1 DEROctetString DEROctetString
public DEROctetString(ASN1Encodable obj) throws IOException
From source file:org.xwiki.crypto.password.internal.kdf.ScryptKDFParams.java
License:Open Source License
/** * Create Scrypt parameters with a key length. * * @param salt is the salt value.//ww w . j av a2 s . c o m * @param costParameter is the CPU/Memory cost parameter N. * @param blockSize is the block size parameter r. * @param parallelizationParameter is the parallelization parameter. * @param keyLength is the length in octets of the derived key. */ public ScryptKDFParams(byte[] salt, int costParameter, int blockSize, int parallelizationParameter, int keyLength) { this.salt = new DEROctetString(salt); this.costParameter = new ASN1Integer(costParameter); this.blockSize = new ASN1Integer(blockSize); this.parallelizationParameter = new ASN1Integer(parallelizationParameter); this.keyLength = (keyLength >= 0) ? new ASN1Integer(keyLength) : null; }
From source file:org.xwiki.crypto.password.internal.pbe.factory.BcPBES2AesCipherFactory.java
License:Open Source License
@Override protected PasswordBasedCipher getPasswordBasedCipher(boolean forEncryption, final KeyDerivationFunction kdf, SymmetricCipherParameters params) { /** Overwrite the key length with itself, since the key length will be encoded in the algorithm identifier */ kdf.overrideKeySize(kdf.getKeySize()); return new AbstractBcPBES2Cipher(getCipherFactory().getInstance(forEncryption, params), kdf, params) { @Override/* w w w . ja va2 s .c o m*/ protected EncryptionScheme getScheme(SymmetricCipherParameters parameters) { return new EncryptionScheme( getAESAlgoritmIdentifier(((KeyWithIVParameters) parameters).getKey().length), new DEROctetString(((KeyWithIVParameters) parameters).getIV())); } }; }
From source file:org.xwiki.crypto.password.internal.pbe.factory.BcPBES2BlowfishCipherFactory.java
License:Open Source License
@Override protected PasswordBasedCipher getPasswordBasedCipher(boolean forEncryption, final KeyDerivationFunction kdf, SymmetricCipherParameters params) { return new AbstractBcPBES2Cipher(getCipherFactory().getInstance(forEncryption, params), kdf, params) { @Override//from w w w . j a v a 2 s .c o m protected EncryptionScheme getScheme(SymmetricCipherParameters parameters) { return new EncryptionScheme(ALG_ID, new DEROctetString(((KeyWithIVParameters) parameters).getIV())); } }; }
From source file:org.xwiki.crypto.password.internal.pbe.factory.BcPBES2DesEdeCipherFactory.java
License:Open Source License
@Override protected PasswordBasedCipher getPasswordBasedCipher(boolean forEncryption, KeyDerivationFunction kdf, SymmetricCipherParameters params) { return new AbstractBcPBES2Cipher(getCipherFactory().getInstance(forEncryption, params), kdf, params) { @Override/*from w w w .j av a 2s. c o m*/ protected EncryptionScheme getScheme(SymmetricCipherParameters parameters) { return new EncryptionScheme(PKCSObjectIdentifiers.des_EDE3_CBC, new DEROctetString(((KeyWithIVParameters) parameters).getIV())); } }; }
From source file:org.xwiki.crypto.password.internal.pbe.RC5CBCParameter.java
License:Open Source License
/** * Create a new instance with the optional initialization vector and a specific parameter version. * @param parameterVersion the version of this parameter structure, should be v1-0 (16). * @param rounds the number of "rounds" in the encryption operation between 8 and 127. * @param blockSizeInBits the block size in bits, may be 64 or 128. * @param iv the initialization vector./*w w w . j a va 2 s . co m*/ */ public RC5CBCParameter(int parameterVersion, int rounds, int blockSizeInBits, byte[] iv) { this.version = new ASN1Integer(parameterVersion); this.rounds = new ASN1Integer(rounds); this.blockSizeInBits = new ASN1Integer(blockSizeInBits); this.iv = (iv != null) ? new DEROctetString(iv) : null; }
From source file:org.xwiki.crypto.pkix.params.x509certificate.extension.X509IpAddress.java
License:Open Source License
@Override public GeneralName getGeneralName() { return new GeneralName(GeneralName.iPAddress, new DEROctetString(this.ipAddress)); }
From source file:passwdmanager.hig.no.lds.DG_SOD.java
private static ContentInfo createContentInfo(String digestAlgorithm, Map<Integer, byte[]> dataGroupHashes) throws NoSuchAlgorithmException { DataGroupHash[] dataGroupHashesArray = new DataGroupHash[dataGroupHashes.size()]; int i = 0;/*w ww. j a v a2 s .c om*/ for (int dataGroupNumber : dataGroupHashes.keySet()) { byte[] hashBytes = dataGroupHashes.get(dataGroupNumber); DataGroupHash hash = new DataGroupHash(dataGroupNumber, new DEROctetString(hashBytes)); dataGroupHashesArray[i++] = hash; } AlgorithmIdentifier digestAlgorithmIdentifier = new AlgorithmIdentifier( lookupOIDByMnemonic(digestAlgorithm), new DERNull()); LDSSecurityObject sObject2 = new LDSSecurityObject(digestAlgorithmIdentifier, dataGroupHashesArray); return new ContentInfo(ICAO_SOD_OID, new DEROctetString(sObject2)); }
From source file:passwdmanager.hig.no.lds.DG_SOD.java
private static SignerInfo createSignerInfo(String digestAlgorithm, String digestEncryptionAlgorithm, byte[] content, byte[] encryptedDigest, X509Certificate docSigningCertificate) throws NoSuchAlgorithmException { /*/*from w w w .j ava2s .c o m*/ * Get the issuer name (CN, O, OU, C) from the cert and put it in a * SignerIdentifier struct. */ X500Principal docSignerPrincipal = ((X509Certificate) docSigningCertificate).getIssuerX500Principal(); X509Name docSignerName = new X509Name(true, docSignerPrincipal.getName()); // RFC 2253 format BigInteger serial = ((X509Certificate) docSigningCertificate).getSerialNumber(); SignerIdentifier sid = new SignerIdentifier(new IssuerAndSerialNumber(docSignerName, serial)); AlgorithmIdentifier digestAlgorithmObject = new AlgorithmIdentifier(lookupOIDByMnemonic(digestAlgorithm), new DERNull()); AlgorithmIdentifier digestEncryptionAlgorithmObject = new AlgorithmIdentifier( lookupOIDByMnemonic(digestEncryptionAlgorithm), new DERNull()); ASN1Set authenticatedAttributes = createAuthenticatedAttributes(digestAlgorithm, content); // struct containing the hash of // content ASN1OctetString encryptedDigestObject = new DEROctetString(encryptedDigest); // this is the signature ASN1Set unAuthenticatedAttributes = null; // should be empty set? return new SignerInfo(sid, digestAlgorithmObject, authenticatedAttributes, digestEncryptionAlgorithmObject, encryptedDigestObject, unAuthenticatedAttributes); }
From source file:passwdmanager.hig.no.lds.DG_SOD.java
private static ASN1Set createAuthenticatedAttributes(String digestAlgorithm, byte[] contentBytes) throws NoSuchAlgorithmException { MessageDigest dig = MessageDigest.getInstance(digestAlgorithm); byte[] digestedContentBytes = dig.digest(contentBytes); ASN1OctetString digestedContent = new DEROctetString(digestedContentBytes); Attribute contentTypeAttribute = new Attribute(RFC_3369_CONTENT_TYPE_OID, createSingletonSet(ICAO_SOD_OID)); Attribute messageDigestAttribute = new Attribute(RFC_3369_MESSAGE_DIGEST_OID, createSingletonSet(digestedContent)); ASN1Encodable[] result = { contentTypeAttribute.toASN1Object(), messageDigestAttribute.toASN1Object() }; return new DERSet(result); }
From source file:prototype.AlwaysValidOcspSource.java
License:GNU General Public License
public OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws DSSException { try {//from ww w . java2 s . co m final DigestCalculator digestCalculator = DSSUtils.getSHA1DigestCalculator(); // Generate the getFileId for the certificate we are looking for CertificateID id = new CertificateID(digestCalculator, new X509CertificateHolder(issuerCert.getEncoded()), serialNumber); // basic request generation with nonce OCSPReqBuilder ocspGen = new OCSPReqBuilder(); ocspGen.addRequest(id); // create details for nonce extension BigInteger nonce = BigInteger.valueOf(ocspDate.getTime()); Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, true, new DEROctetString(nonce.toByteArray())); ocspGen.setRequestExtensions(new Extensions(new Extension[] { ext })); return ocspGen.build(); } catch (OCSPException e) { throw new DSSException(e); } catch (IOException e) { throw new DSSException(e); } catch (CertificateEncodingException e) { throw new DSSException(e); } }