use of com.unboundid.asn1.ASN1Null in project openkeystore by cyberphone.
the class PKCS7Signer method sign.
private byte[] sign(byte[] message, boolean detached) throws IOException, GeneralSecurityException {
ArrayList<BaseASN1Object> cert_path = new ArrayList<>();
for (X509Certificate c : certificatePath) {
cert_path.add(ASN1Util.x509Certificate(c));
}
BaseASN1Object signer_cert = cert_path.get(0);
int i = ParseUtil.isContext(signer_cert.get(new int[] { 0, 0 }), 0) ? 1 : 0;
BaseASN1Object sign_info = signer_cert.get(new int[] { 0, i + 2 });
BaseASN1Object cert_ref = signer_cert.get(new int[] { 0, i });
String digest_oid = signer_implem.getAlgorithm().getDigestAlgorithm().getOid();
String encryption_oid = AsymEncryptionAlgorithms.RSA_ES_PKCS_1_5.getOid();
byte[] signed_data = signer_implem.signData(message);
BaseASN1Object r = ASN1Util.oidValue(PKCS7_SIGNED_DATA, new CompositeContextSpecific(0, new ASN1Sequence(new BaseASN1Object[] { new ASN1Integer(1), ASN1Util.oidValueSet(digest_oid, new ASN1Null()), detached ? new ASN1Sequence((BaseASN1Object) new ASN1ObjectID(PKCS7_DATA)) : (BaseASN1Object) ASN1Util.oidValue(PKCS7_DATA, new CompositeContextSpecific(0, new ASN1OctetString(message))), new CompositeContextSpecific(0, cert_path), new ASN1Set(new ASN1Sequence(new BaseASN1Object[] { new ASN1Integer(1), new ASN1Sequence(new BaseASN1Object[] { sign_info, cert_ref }), ASN1Util.oidNull(digest_oid), ASN1Util.oidNull(encryption_oid), new ASN1OctetString(signed_data) })) })));
return r.encode();
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Write2EnabledAll.
/**
* Tests the second {@code debugASN1Write} method with the debugger enabled
* and a debug type set of all types.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Write2EnabledAll() throws Exception {
Debug.setEnabled(true);
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Write(Level.FINEST, new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Read2EnabledOnlyASN1.
/**
* Tests the second {@code debugASN1Read} method with the debugger enabled
* and a debug type set that includes only the ASN.1 type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Read2EnabledOnlyASN1() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.ASN1));
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Read(Level.FINEST, new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Write1EnabledAll.
/**
* Tests the first {@code debugASN1Write} method with the debugger enabled
* and a debug type set of all types.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Write1EnabledAll() throws Exception {
Debug.setEnabled(true);
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Write(new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Write2EnabledIncludeASN1.
/**
* Tests the second {@code debugASN1Write} method with the debugger enabled
* and a debug type set that includes the ASN.1 type among others.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Write2EnabledIncludeASN1() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.ASN1, DebugType.OTHER));
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Write(Level.FINEST, new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 1);
}
Aggregations