Skip to content

Commit

Permalink
Fix wultra#370: Fix minor issues from code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
petrdvorak committed May 5, 2021
1 parent 3da4632 commit aa6698e
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/Activation-Code.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Activation Code

The PowerAuth protocol 3, defines a new version of activation code, where OTP<sup>1</sup> is no longer applied. The format of the code is the same (four groups, each group is composed from five Base32 characters), but the code is no longer split into `OTP` and `SHORT_ID` parts. The new code has following features:
The PowerAuth protocol 3, defines a new version of activation code, where OTP<sup>1</sup> is no longer applied. The format of the code is the same (four groups, each group is composed of five Base32 characters), but the code is no longer split into `OTP` and `SHORT_ID` parts. The new code has following features:

- The whole code is now a short activation identifier, and we call it simply `ACTIVATION_CODE`. This principally means, that the code is no longer used in the cryptographic calculations.
- The code is using `CRC-16/ARC` to detect a typing errors. This is useful for scenarios, where the user needs to re-type the code manually.
Expand Down
2 changes: 1 addition & 1 deletion docs/PowerAuth-2017.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ In case you are updating from older versions of PA stack, you might meet followi

```java
public class MyEncryptedObjectResponse<T> extends ObjectResponse<T> {
private String encryption = "nonpersonalized";
private final String encryption = "nonpersonalized";
// ... getters and setters
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
public class ClientNonPersonalizedEncryptor {

private NonPersonalizedEncryptor encryptor;
private final NonPersonalizedEncryptor encryptor;

private final KeyConvertor keyConvertor = new KeyConvertor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum EciesSharedInfo1 {
CREATE_TOKEN("/pa/token/create"),
CONFIRM_RECOVERY_CODE("/pa/recovery/confirm");

private byte[] value;
private final byte[] value;

/**
* Constructor with sharedInfo1 parameter for ECIES.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public enum PowerAuthDerivedKey {
*/
ENCRYPTED_VAULT(2000);

private long index;
private final long index;

private final static Map<Long, PowerAuthDerivedKey> map = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public enum PowerAuthSignatureTypes {
*/
POSSESSION_KNOWLEDGE_BIOMETRY("possession_knowledge_biometry");

private String value;
private final String value;

private final static Map<String, PowerAuthSignatureTypes> map = new HashMap<>();

Expand All @@ -77,14 +77,10 @@ public enum PowerAuthSignatureTypes {
* @return Enum value.
*/
public static PowerAuthSignatureTypes getEnumFromString(String value) {
if (value != null) {
final PowerAuthSignatureTypes type = map.get(value.toLowerCase());
if (type != null) {
return type;
}
if (value == null) {
return null;
}
// Otherwise return null
return null;
return map.get(value.toLowerCase());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ public RecoveryInfo generateRecoveryCode(SecretKey secretKey, int pukCount, bool
final Map<Integer, String> puks = new LinkedHashMap<>();

for (int i = 1; i <= pukCount; i++) {
Long derivationIndex;
long derivationIndex;
String derivedPuk;
int derivationAttempt = 0;
do {
// Generate random derivation index
byte[] derivationIndexBytes = keyGenerator.generateRandomBytes(8);
final byte[] derivationIndexBytes = keyGenerator.generateRandomBytes(8);
derivationIndex = ByteBuffer.wrap(derivationIndexBytes).getLong();
// Generate recovery PUK
derivedPuk = generatePuk(recoveryPukBaseKey, derivationIndexBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class PublicKeyValidator {
*
* @param curve EC curve.
* @param point EC point.
* @throws GenericCryptoException In case the EC point validation fails.
*/
public void validate(ECCurve curve, ECPoint point) throws GenericCryptoException {
if (point.isInfinity()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class PowerAuthEncryptionHttpHeader extends PowerAuthHttpHeader {
/**
* Class with keys used in the underlying map.
*/
public class Key {
public static class Key {

/**
* Key representing the "application_key" in the PowerAuth encryption header.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class PowerAuthSignatureHttpHeader extends PowerAuthHttpHeader {
/**
* Class with keys used in the underlying map.
*/
public class Key {
public static class Key {

/**
* Key representing the "pa_activation_id" in the PowerAuth authorization header.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class PowerAuthTokenHttpHeader extends PowerAuthHttpHeader {
/**
* Class with keys used in the underlying map.
*/
public class Key {
public static class Key {

/**
* Key representing the "token_id" in the PowerAuth token header.
Expand Down

0 comments on commit aa6698e

Please sign in to comment.