This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from google/acz1
Parse and display block mode and key size
- Loading branch information
Showing
7 changed files
with
301 additions
and
62 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
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
50 changes: 50 additions & 0 deletions
50
u2f-ref-code/java/src/com/google/u2f/server/impl/attestation/android/BlockMode.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,50 @@ | ||
package com.google.u2f.server.impl.attestation.android; | ||
|
||
import java.security.cert.CertificateParsingException; | ||
|
||
/** | ||
* Keymaster block mode values as taken from: keymaster_defs.h / KeymasterDefs.java | ||
*/ | ||
public enum BlockMode { | ||
KM_MODE_ECB(1, "ecb"), | ||
KM_MODE_CBC(2, "cbc"), | ||
KM_MODE_CTR(3, "ctr"), | ||
KM_MODE_GCM(32, "gcm"); | ||
|
||
private final int value; | ||
private final String description; | ||
|
||
public static BlockMode fromValue(int value) throws CertificateParsingException { | ||
for (BlockMode mode : BlockMode.values()) { | ||
if (mode.getValue() == value) { | ||
return mode; | ||
} | ||
} | ||
|
||
throw new CertificateParsingException("Invalid block mode value: " + value); | ||
} | ||
|
||
public static BlockMode fromString(String string) throws CertificateParsingException { | ||
for (BlockMode mode : BlockMode.values()) { | ||
if (mode.toString().equals(string)) { | ||
return mode; | ||
} | ||
} | ||
|
||
throw new CertificateParsingException("Invalid block mode string: " + string); | ||
} | ||
|
||
private BlockMode(int value, String description) { | ||
this.value = value; | ||
this.description = description; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return description; | ||
} | ||
} |
Oops, something went wrong.