OxalisCommunity / oxalis

Oxalis - PEPPOL Access Point open source implementation - Core component
Other
129 stars 91 forks source link

Verify and re-enable integration tests in OxalisCipherTest #69

Closed teedjay closed 11 years ago

teedjay commented 11 years ago

The following two tests was temporarily disabled in check in : https://github.com/difi/oxalis/commit/a11332d6dccd45cd379e06eccf8ec0edb7144ff9

@Test(groups = {"integration"}, dataProvider = "keypair", enabled=false)
public void encryptDataEncryptKeyAndDecrypt(KeyPair keyPair) throws Exception {

@Test(groups = {"integration"}, dataProvider = "keypair", enabled=false)
public void encryptDataWrapKeyAndDecrypt(KeyPair keyPair) throws Exception

The stack trace when running -Pit-test was :

eu.peppol.security.UnwrapSymmetricKeyException: Unable to unwrap and decrypt wrapped symmetric key; Unwrapping failed
    at eu.peppol.security.OxalisCipherConverter.createCipherFromWrappedHexKey(OxalisCipherConverter.java:53)
    at eu.peppol.security.OxalisCipherTest.encryptDataEncryptKeyAndDecrypt(OxalisCipherTest.java:90)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.security.InvalidKeyException: Unwrapping failed
    at com.sun.crypto.provider.RSACipher.engineUnwrap(RSACipher.java:431)
    at javax.crypto.Cipher.unwrap(Cipher.java:2466)
    at eu.peppol.security.OxalisCipherConverter.createCipherFromWrappedHexKey(OxalisCipherConverter.java:42)
    ... 31 more
Caused by: javax.crypto.BadPaddingException: Data must start with zero
    at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:325)
    at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:272)
    at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:356)
    at com.sun.crypto.provider.RSACipher.engineUnwrap(RSACipher.java:427)
    ... 33 more
steinarcook commented 11 years ago

Turned out that the private key and public key was not part of the same pair.