-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Fix #451: Allow overriding length of decimalized singatures - Change code based on code review - Fix test vector - Fix JavaDoc - Add invalid format to exception message (cherry picked from commit 6d81bf1) Co-authored-by: Petr Dvořák <[email protected]>
- Loading branch information
Showing
12 changed files
with
3,137 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,604 changes: 2,604 additions & 0 deletions
2,604
powerauth-docs/test-vectors/signatures-offline.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...in/java/io/getlime/security/powerauth/crypto/lib/config/Base64SignatureConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* PowerAuth Crypto Library | ||
* Copyright 2023 Wultra s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.getlime.security.powerauth.crypto.lib.config; | ||
|
||
import io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureFormat; | ||
|
||
/** | ||
* Configuration for Base64 signatures. | ||
* | ||
* @author Petr Dvorak, [email protected] | ||
*/ | ||
public class Base64SignatureConfiguration extends SignatureConfiguration { | ||
|
||
/** | ||
* Constructor with the base64 signature. Package scoped. | ||
*/ | ||
Base64SignatureConfiguration() { | ||
super(PowerAuthSignatureFormat.BASE64); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...n/java/io/getlime/security/powerauth/crypto/lib/config/DecimalSignatureConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* PowerAuth Crypto Library | ||
* Copyright 2023 Wultra s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.getlime.security.powerauth.crypto.lib.config; | ||
|
||
import io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureFormat; | ||
|
||
/** | ||
* Configuration for decimal signatures. | ||
* | ||
* @author Petr Dvorak, [email protected] | ||
*/ | ||
public class DecimalSignatureConfiguration extends SignatureConfiguration { | ||
|
||
private Integer length; | ||
|
||
/** | ||
* Constructor with the decimal signature. Package scoped. | ||
*/ | ||
DecimalSignatureConfiguration() { | ||
super(PowerAuthSignatureFormat.DECIMAL); | ||
} | ||
|
||
/** | ||
* Constructor with signature length. Package scoped. | ||
* | ||
* @param length Length. | ||
*/ | ||
DecimalSignatureConfiguration(Integer length) { | ||
super(PowerAuthSignatureFormat.DECIMAL); | ||
this.length = length; | ||
} | ||
|
||
/** | ||
* Get length of signature. | ||
* | ||
* @return Length of signature. | ||
*/ | ||
public Integer getLength() { | ||
return length; | ||
} | ||
|
||
/** | ||
* Set length of the signature. | ||
* | ||
* @param length Length of signature. | ||
*/ | ||
public void setLength(Integer length) { | ||
this.length = length; | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...src/main/java/io/getlime/security/powerauth/crypto/lib/config/SignatureConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* PowerAuth Crypto Library | ||
* Copyright 2023 Wultra s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.getlime.security.powerauth.crypto.lib.config; | ||
|
||
import io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureFormat; | ||
import io.getlime.security.powerauth.crypto.lib.model.exception.CryptoProviderException; | ||
|
||
/** | ||
* Class that holds information about the signature configuration. | ||
* | ||
* @author Petr Dvorak, [email protected] | ||
*/ | ||
public abstract class SignatureConfiguration { | ||
|
||
private final PowerAuthSignatureFormat signatureFormat; | ||
|
||
/** | ||
* Constructor with the signature format. | ||
* | ||
* @param signatureFormat Signature format. | ||
*/ | ||
public SignatureConfiguration(PowerAuthSignatureFormat signatureFormat) { | ||
this.signatureFormat = signatureFormat; | ||
} | ||
|
||
/** | ||
* Get signature format. | ||
* @return Signature format. | ||
*/ | ||
public PowerAuthSignatureFormat getSignatureFormat() { | ||
return signatureFormat; | ||
} | ||
|
||
public static SignatureConfiguration forFormat(PowerAuthSignatureFormat format) throws CryptoProviderException { | ||
switch (format) { | ||
case BASE64: { | ||
return new Base64SignatureConfiguration(); | ||
} | ||
case DECIMAL: { | ||
return new DecimalSignatureConfiguration(); | ||
} | ||
} | ||
throw new CryptoProviderException("Invalid or null format provided: " + format); | ||
} | ||
|
||
/** | ||
* Construct new decimal signature of default length. | ||
* | ||
* @return Decimal signature with default length. | ||
*/ | ||
public static DecimalSignatureConfiguration decimal() { | ||
return new DecimalSignatureConfiguration(); | ||
} | ||
|
||
/** | ||
* Construct new decimal signature of given length. | ||
* | ||
* @param length Length. | ||
* @return Decimal signature with given length. | ||
*/ | ||
public static DecimalSignatureConfiguration decimal(Integer length) { | ||
return new DecimalSignatureConfiguration(length); | ||
} | ||
|
||
/** | ||
* Construct new Base64 signature. | ||
* | ||
* @return Base64 signature. | ||
*/ | ||
public static Base64SignatureConfiguration base64() { | ||
return new Base64SignatureConfiguration(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.