Giter Club home page Giter Club logo

secon-tool's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

secon-tool's Issues

Verification of valid/strong encryption algorithm

Anlage 16 defines aes256-CBC as default encryption algorithm. apsec/fideAS health center checks for exactly this algorithm. While "default" leaves room for interpretation, the tool should check for strong algorithms in decryption mode.

Please refer to bitmarck-service#4 for a draft implementation

Add cache for LDAP certificates

Currently, secon-tool supports loading certificates from LDAP servers directly. This works well for environments where highly available access to at least 1 LDAP server can be ensured. In order to improve operability in environments where LDAP availability is not guaranteed to be highly available it would be desirable to have cached certificate data available. This would allow functionality even in case of temporarily unavailable LDAP servers. As certificate data for a given organisation changes only every few years, there is relatively low risk for using outdated certificate information.

Clarify license situation

The project does not have any license information, nor are there any license headers in the source files. Is this project supposed to be Open Source? As is, the code should be considered proprietary and cannot be safely used by anyone.

Please attach an Open Source license to the project or clarify the licensing otherwise.

(Non-)usage of parameter "employerNumber" in "sign" and "decrypt"

In PKCS7EncryptionServiceImpl in methods sign and decrypt the respective parameters employerNumber are never used (for the latter only as part of an exception message). Instead PKCS7KeyLocator is called without any arguments.

Thus changing the values used in the provided JUnit test methods (i.e. a different values inside both signAndEncrypt and decryptAndVerify) also yields constant success.

Is this intended?

Please consider renaming this repository

This is only a suggestion with the following motivation:

Currently, this repository is named kks-encryption. This is a bit misleading because encryption is only one of four operations this library actually does, with the other being signing, verifying and decryption. Plus, this library also has additional features to use Java keystores for proving identity, looking up certificates or using an LDAP for looking up certificates and also general I/O tasks like fast copying of data.

Therefore, I would like to propose to rename this repository to "kks-tool" instead. This would also reflect the fact that you can use the fat-jar of this library as a command line tool.

Add fun-io-bios library to JAR

When trying to use the released version of the secon-tool, I realized the dependency global.namespace.fun-io:fun-io-bios:2.4.0 was missing and had to be added in our pom.xml. After checking the released pom file for the secon-tool I realised that the dependencies are defined with <scope>runtime</scope>, is this intended?

For the bouncycastle dependency this is actually quite beneficial as it avoids clashes with the already existing bouncycastle version in our implementation, but for the fun-io-bios I would prefer to get the dependency from the secon-tool library as we do not use it anywhere else.

    <dependency>
      <groupId>global.namespace.fun-io</groupId>
      <artifactId>fun-io-bios</artifactId>
      <version>2.4.0</version>
      <scope>runtime</scope>
    </dependency>

Error shown when using trying to compile the project without specifying the fun-io-bios in the projects pom.xml:

java: cannot access global.namespace.fun.io.api.Socket
  class file for global.namespace.fun.io.api.Socket not found

Ist es ein Fehler wegen Signatur oder was für ein Problem haben wir?

Sehr geehrte Damen und Herren,
wir haben bis jetzt für Document Management System die Produktpalette von Axway verwendet. Zurzeit haben wir eine Umstellung von Axway PassPort, das verwaltet den gesamt LDAP System und unsere Beratern von Axway haben uns Secon Tool empfohlen. Wir haben die Einstellungen schon richtig gemacht und alles unter Axway B2Bi eingestellt und die Umstellung gemacht. Zurzeit bekommen wir von manchen Dokumenten (nicht von allen) die folgende Fehlermeldung:
Exception in thread "main" de.tk.opensource.secon.SeconException: java.io.IOException: org.bouncycastle.cms.CMSException: The content-type attribute type MUST be present whenever signed attributes are present in signed-dataXXat de.tk.openso urce.secon.SECON.lambda$6(SECON.java:268)XXat de.tk.opensource.secon.SECON.call(SECON.java:256)XXat de.tk.opensource.secon.SECON.copy(SECON.java:245)XXat de.tk.opensource.secon.Main.run(Main.java:126)XXat de.tk.opensource.secon.Main.main(Ma in.java:31)XCaused by: java.io.IOException: org.bouncycastle.cms.CMSException: The content-type attribute type MUST be present whenever signed attributes are present in signed-dataXXat de.tk.opensource.secon.DefaultSubscriber$1.verifyIo(Def aultSubscriber.java:208)XXat de.tk.opensource.secon.SideEffect.lambda$0(SideEffect.java:50)XXat de.tk.opensource.secon.SideEffect.runAll(SideEffect.java:35)XXat de.tk.opensource.secon.DefaultSubscriber$1.close(DefaultSubscriber.java:199)XXa t de.tk.opensource.secon.SideEffect.lambda$0(SideEffect.java:44)XXat de.tk.opensource.secon.SideEffect.runAll(SideEffect.java:35)XXat de.tk.opensource.secon.Streams$1.close(Streams.java:41)XXat global.namespace.fun.io.api.Socket.accept(Sock et.java:111)XXat global.namespace.fun.io.spi.Copy.copy(Copy.java:91)XXat global.namespace.fun.io.bios.BIOS.copy(BIOS.java:537)XXat de.tk.opensource.secon.SECON.lambda$4(SECON.java:246)XXat de.tk.opensource.secon.SECON.lambda$6(SECON.java:26 2)XX... 4 moreXCaused by: org.bouncycastle.cms.CMSException: The content-type attribute type MUST be present whenever signed attributes are present in signed-dataXXat org.bouncycastle.cms.SignerInformation.doVerify(Unknown Source)XXat org.b ouncycastle.cms.SignerInformation.verify(Unknown Source)XXat de.tk.opensource.secon.DefaultSubscriber$1.verify(DefaultSubscriber.java:219)XXat de.tk.opensource.secon.DefaultSubscriber$1.verifyIo(DefaultSubscriber.java:204)XX... 15 moreX; MBC179 - Sonstige Fehler bei der Entschluesselung und oder Signature Pruefung, BN: 04373776 StdERR >Exception in thread "main" de.tk.opensource.secon.SeconException: java.io.IOException: org.bouncycastle.cms.CMSException: The content-type attribute type MUST be present whenever signed attributes are present in signed-dataXXat de.tk.openso urce.secon.SECON.lambda$6(SECON.java:268)XXat de.tk.opensource.secon.SECON.call(SECON.java:256)XXat de.tk.opensource.secon.SECON.copy(SECON.java:245)XXat de.tk.opensource.secon.Main.run(Main.java:126)XXat de.tk.opensource.secon.Main.main(Ma in.java:31)XCaused by: java.io.IOException: org.bouncycastle.cms.CMSException: The content-type attribute type MUST be present whenever signed attributes are present in signed-dataXXat de.tk.opensource.secon.DefaultSubscriber$1.verifyIo(Def aultSubscriber.java:208)XXat de.tk.opensource.secon.SideEffect.lambda$0(SideEffect.java:50)XXat de.tk.opensource.secon.SideEffect.runAll(SideEffect.java:35)XXat de.tk.opensource.secon.DefaultSubscriber$1.close(DefaultSubscriber.java:199)XXa t de.tk.opensource.secon.SideEffect.lambda$0(SideEffect.java:44)XXat de.tk.opensource.secon.SideEffect.runAll(SideEffect.java:35)XXat de.tk.opensource.secon.Streams$1.close(Streams.java:41)XXat global.namespace.fun.io.api.Socket.accept(Sock et.java:111)XXat global.namespace.fun.io.spi.Copy.copy(Copy.java:91)XXat global.namespace.fun.io.bios.BIOS.copy(BIOS.java:537)XXat de.tk.opensource.secon.SECON.lambda$4(SECON.java:246)XXat de.tk.opensource.secon.SECON.lambda$6(SECON.java:26 2)XX... 4 moreXCaused by: org.bouncycastle.cms.CMSException: The content-type attribute type MUST be present whenever signed attributes are present in signed-dataXXat org.bouncycastle.cms.SignerInformation.doVerify(Unknown Source)XXat org.b ouncycastle.cms.SignerInformation.verify(Unknown Source)XXat de.tk.opensource.secon.DefaultSubscriber$1.verify(DefaultSubscriber.java:219)XXat de.tk.opensource.secon.DefaultSubscriber$1.verifyIo(DefaultSubscriber.java:204)XX... 15 moreX

Obwohl ich Senior Java Entwickler bin, habe ich in meiner Arbeitsumgebung andere Rolle und deshalb habe ich leider keine IDEs . Deshalb konnte ich den Quellcode nicht richtig debuggen. Ich habe folgende Fragen:

  1. Was müssen wir noch auf Axway Backend "Message Builder Component - MBC" System achten oder umprogrammieren?
  2. Geht es hier um fehlende Signaturen?

Vielen Dank für Ihre Unterstützung im Voraus.

Mit freundlichen Grüßen

Hürol Türen

Doesn't compile on Java 8

Currently the build fails to compile on Java 8 for two main reasons:

options.release.set(8) only works on Java > 8 and will throw: invalid flag: --release
Proposed workaround: use sourceCompatibility = "1.8" and targetCompatibility = "1.8"

compileJava fails in DirContextVisitor
src\main\java\de\tk\security\kks\DirContextVisitor.java:40: error: incompatible types: cannot infer type-variable(s) T .from(attr::getAll) ^ (argument mismatch; invalid method reference getAll() in Attribute is defined in an inaccessible class or interface) where T is a type-variable: T extends Object declared in method <T>from(Callable<NamingEnumeration<T>>) 1 error

tested with JDK 1.8.0_221

SECON uses BouncyCastleProvider with old version 1.68

Hi everyone,

I am experiencing some version issues with the secon tool. I am getting a no such field issue when I try to SECON.copy my payload:

java.lang.NoSuchFieldError: id_RSASSA_PSS_SHAKE128 at org.bouncycastle.operator.DefaultSignatureNameFinder.<clinit>(Unknown Source) at org.bouncycastle.operator.jcajce.OperatorHelper.<clinit>(Unknown Source) at org.bouncycastle.operator.jcajce.JceAsymmetricKeyWrapper.<init>(Unknown Source) at org.bouncycastle.cms.jcajce.JceKeyTransRecipientInfoGenerator.<init>(Unknown Source) at de.tk.opensource.secon.RecipientInfoGeneratorFactory.create(RecipientInfoGeneratorFactory.java:50) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at de.tk.opensource.secon.DefaultSubscriber.encrypt(DefaultSubscriber.java:206) at de.tk.opensource.secon.DefaultSubscriber.lambda$encrypt$3(DefaultSubscriber.java:215) at de.tk.opensource.secon.Streams.lambda$fixOutputstreamClose$1(Streams.java:48) at global.namespace.fun.io.api.function.XFunction.lambda$compose$0(XFunction.java:32) at global.namespace.fun.io.api.Socket.lambda$map$0(Socket.java:138) at de.tk.opensource.secon.SECON.lambda$callable$4(SECON.java:261) at global.namespace.fun.io.api.Socket.accept(Socket.java:109) at global.namespace.fun.io.spi.Copy.lambda$copy$3(Copy.java:91) at global.namespace.fun.io.api.Socket.accept(Socket.java:110) at global.namespace.fun.io.spi.Copy.copy(Copy.java:91) at global.namespace.fun.io.bios.BIOS.copy(BIOS.java:537) at de.tk.opensource.secon.SECON.lambda$copy$3(SECON.java:245) at de.tk.opensource.secon.SECON.lambda$callable$4(SECON.java:261) at de.tk.opensource.secon.SECON.call(SECON.java:255) at de.tk.opensource.secon.SECON.copy(SECON.java:244)

As per the current gradle file in version 1.1.1, Bouncycastle 1.70 is used. Nevertheless, the BouncycastleProvider that is instantiated is, 1.68 (SECON.java:115). Bouncycastle 1.68 does not seem to have that field.

Just wanted to know, if this is a general version issue or some strange dependency phenomenon on my side.

Thanks in advance and kind regards

use RSAES-OAEP algorithm for 4096 bit keys

According to the specification in SECON (section 2.1.4) for 4096 bit RSA-keys the RSAES-OAEP algorithm should be used to encrypt the session key.
Currently the tool uses the algorithm implied by the public key of the encryption certificate which defaults to RSA (PKCS#1 v1.5).
This causes interoperability issues when decrypting messages created with secon-tool using other tools expecting RSAES-OAEP instead of RSA.

CertificateNotFoundException

Hi,
when sending files to the insurance company, we get this error:

VERIFY: iaik.cms.CertificateNotFoundException: Certificate for verifying the signature not found!

At the moment we are stuck, because we don't have a glue, why this happens.
Kubus says, they do have our new 4k certificate.
When signing and encrypting the file, there is no error message.
In our opinion, the keystore is fine, we imported the root and our certificates.
How can we test this or find this error?

Thanks in advance.

RSASSA-PSS 4096 doesn't work

There seems to be a problem with RSA keys with 4096 bits and the RSASSA-PSS algorithm when the private keys and certificates are generated by the keytool. Here is a transcript demonstrating that it works with 2048 bits, but not 4096 bits:

$ echo 'Hello world' > message.txt
$ keytool -keystore keystore.p12 -storepass secret -storetype PKCS12 -genkeypair -alias test2k -dname "cn=Test 2048" -keyalg rsa -keysize 2048 -sigalg rsassa-pss
Generating 2.048 bit RSA key pair and self-signed certificate (RSASSA-PSS) with a validity of 90 days
	for: CN=Test 2048
$ keytool -keystore keystore.p12 -storepass secret -storetype PKCS12 -genkeypair -alias test4k -dname "cn=Test 4096" -keyalg rsa -keysize 4096 -sigalg rsassa-pss
Generating 4.096 bit RSA key pair and self-signed certificate (RSASSA-PSS) with a validity of 90 days
	for: CN=Test 4096
$ java -jar build/libs/kks-0.0.1-SNAPSHOT-all.jar -keystore keystore.p12 -storepass secret -alias test2k -recipient test2k -source message.txt -sink message.cms
$ java -jar build/libs/kks-0.0.1-SNAPSHOT-all.jar -keystore keystore.p12 -storepass secret -alias test2k -source message.cms -sink /dev/tty
Hello world
$ java -jar build/libs/kks-0.0.1-SNAPSHOT-all.jar -keystore keystore.p12 -storepass secret -alias test4k -recipient test4k -source message.txt -sink message.cms
$ java -jar build/libs/kks-0.0.1-SNAPSHOT-all.jar -keystore keystore.p12 -storepass secret -alias test4k -source message.cms -sink /dev/tty
Hello world
Exception in thread "main" de.tk.security.kks.KksInvalidSignatureException
	at de.tk.security.kks.KksSubscriber$1.verify(KksSubscriber.java:180)
	at de.tk.security.kks.KksSubscriber$1.verifyIo(KksSubscriber.java:165)
	at de.tk.security.kks.SideEffect.lambda$andThen$0(SideEffect.java:46)
	at de.tk.security.kks.SideEffect.runAll(SideEffect.java:31)
	at de.tk.security.kks.KksSubscriber$1.close(KksSubscriber.java:160)
	at de.tk.security.kks.SideEffect.lambda$andThen$0(SideEffect.java:40)
	at de.tk.security.kks.SideEffect.runAll(SideEffect.java:31)
	at de.tk.security.kks.Streams$1.close(Streams.java:37)
	at global.namespace.fun.io.api.Socket.accept(Socket.java:111)
	at global.namespace.fun.io.spi.Copy.copy(Copy.java:91)
	at global.namespace.fun.io.bios.BIOS.copy(BIOS.java:537)
	at de.tk.security.kks.KKS.lambda$copy$3(KKS.java:237)
	at de.tk.security.kks.KKS.lambda$callable$4(KKS.java:253)
	at de.tk.security.kks.KKS.call(KKS.java:247)
	at de.tk.security.kks.KKS.copy(KKS.java:236)
	at de.tk.security.kks.Main.run(Main.java:104)
	at de.tk.security.kks.Main.main(Main.java:42)
$ 

Debugging the problem doesn't help because the validation fails in BC and the byte code in their lib doesn't have debugging infos. However, I suspect the problem in the special setup for keys of 4096 bits or more. This is happening in KksSubscriber.java.

Is this a bug or a feature? I would expect the tool to work with any proper sigalg and keysize, but it doesn't.

Use embedded certificates

CMS (Cryptographic Message Syntax) supports to embed a certificate chain (same concept as in TLS). This should be supported by the SECON-tool, too, so that a recipient has a chance to verify a message even if they don't have the latest certificate chain. For full support, the SECON-tool would need to

  1. Embed the certificate chain when signing a message.
  2. Verify an embedded certificate chain when verifying the signature(s) of a message.

This feature could help with a certificate renewal if the message receiver does not already have the certificate(s) used to sign the message.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.