Be more forgiving in parsing verifier IDs

RFC 4648's Base32 is made to be forgiving for users doing manual entry
of the digits. For this reason we want to be able to parse lowercase
letters as uppercase and number 0 (zero) as letter O along with number
1 (one) as letter I.

Change-Id: Ide760aff84f97c3e06af8bf8d006f36c74033a41
This commit is contained in:
Kenny Root
2011-09-14 09:57:27 -07:00
parent 16066ec591
commit a0f264e1af
2 changed files with 42 additions and 4 deletions

View File

@@ -153,6 +153,15 @@ public class VerifierDeviceIdentity implements Parcelable {
value = group - ('2' - 26);
} else if (group == SEPARATOR) {
continue;
} else if ('a' <= group && group <= 'z') {
/* Lowercase letters should be the same as uppercase for Base32 */
value = group - 'a';
} else if (group == '0') {
/* Be nice to users that mistake O (letter) for 0 (zero) */
value = 'O' - 'A';
} else if (group == '1') {
/* Be nice to users that mistake I (letter) for 1 (one) */
value = 'I' - 'A';
} else {
throw new IllegalArgumentException("base base-32 character: " + group);
}