/** * return the DER encoding of the signed attributes. * @throws IOException if an encoding error occurs. */ public byte[] getEncodedSignedAttributes() throws IOException { if (signedAttributeSet != null) { return signedAttributeSet.getEncoded(ASN1Encoding.DER); } return null; }
/** * return the DER encoding of the signed attributes. * @throws IOException if an encoding error occurs. */ public byte[] getEncodedSignedAttributes() throws IOException { if (signedAttributeSet != null) { return signedAttributeSet.getEncoded(ASN1Encoding.DER); } return null; }
byte[] a = getEncoded((ASN1Encodable)set.elementAt(0)); byte[] b = getEncoded((ASN1Encodable)set.elementAt(index + 1));
/** Realiza la firma usando los atributos del firmante. * @param signatureAlgorithm Algoritmo para la firma. * @param keyEntry Clave para firmar. * @return Firma de los atributos. * @throws InvalidKeyException Cuando hay problemas de adecuación de la clave. * @throws NoSuchAlgorithmException Si el JRE no soporta algún algoritmo necesario * @throws IOException Cuando hay problemas de entrada / salida. * @throws SignatureException Cuando ocurren problemas en la firma PKCS#1 */ private ASN1OctetString firma(final String signatureAlgorithm, final PrivateKeyEntry keyEntry) throws InvalidKeyException, NoSuchAlgorithmException, IOException, SignatureException { final Signature sig = Signature.getInstance(signatureAlgorithm); final byte[] tmp = this.signedAttr2.getEncoded(ASN1Encoding.DER); // Indicar clave privada para la firma sig.initSign(keyEntry.getPrivateKey()); // Actualizamos la configuracion de firma sig.update(tmp); // firmamos y devolvemos. return new DEROctetString(sig.sign()); }
final byte[] tmp = signedAttr2.getEncoded(ASN1Encoding.DER);
/** * Return the MAC calculated for the recipient. Note: this call is only meaningful once all * the content has been read. * * @return byte array containing the mac. */ public byte[] getMac() { if (resultMac == null) { if (operator.isMacBased()) { if (additionalData != null) { try { Streams.drain(operator.getInputStream(new ByteArrayInputStream(additionalData.getAuthAttributes().getEncoded(ASN1Encoding.DER)))); } catch (IOException e) { throw new IllegalStateException("unable to drain input: " + e.getMessage()); } } resultMac = operator.getMac(); } } return resultMac; }
/** * Return the MAC calculated for the recipient. Note: this call is only meaningful once all * the content has been read. * * @return byte array containing the mac. */ public byte[] getMac() { if (resultMac == null) { if (operator.isMacBased()) { if (additionalData != null) { try { Streams.drain(operator.getInputStream(new ByteArrayInputStream(additionalData.getAuthAttributes().getEncoded(ASN1Encoding.DER)))); } catch (IOException e) { throw new IllegalStateException("unable to drain input: " + e.getMessage()); } } resultMac = operator.getMac(); } } return resultMac; }
return signedAttributes.getEncoded(ASN1Encoding.DER);
mOut.write(authed.getEncoded(ASN1Encoding.DER));
mOut.write(authed.getEncoded(ASN1Encoding.DER));
sOut.write(signedAttr.getEncoded(ASN1Encoding.DER));
mOut.write(authed.getEncoded(ASN1Encoding.DER));
mOut.write(authed.getEncoded(ASN1Encoding.DER));
sOut.write(signedAttr.getEncoded(ASN1Encoding.DER));
ASN1TaggedObject tagsig = (ASN1TaggedObject)signerInfo.getObjectAt(next); ASN1Set sseq = ASN1Set.getInstance(tagsig, false); sigAttr = sseq.getEncoded(); sigAttrDer = sseq.getEncoded(ASN1Encoding.DER);
authAttr.getEncoded(ASN1Encoding.DER), this.cipherKey );
final byte[] mac = Utils.genMac(autenticationAlgorithm, authAttr.getEncoded(ASN1Encoding.DER), cipherKey);
final byte[] mac = Utils.genMac(autenticationAlgorithm, genPack(authAttr.getEncoded(ASN1Encoding.DER), content2), cipherKey);
envGen.getRawOutputStream().write(recipients.getEncoded());
envGen.getRawOutputStream().write(recipients.getEncoded());