Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8290532: Adjust PKCS11Exception and handle more PKCS11 error codes #700

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -209,14 +209,37 @@ static enum RV {
}
};

public static enum RV_VENDOR {
// NSS
CKR_NSS_CERTDB_FAILED(0xCE534351L),
CKR_NSS_KEYDB_FAILED(0xCE534352L);

private final long value;

RV_VENDOR(long value) {
this.value = value;
}
};

private static String lookup(long errorCode) {
for (RV r : RV.values()) {
if (r.value == errorCode) {
return r.name();
}
}
// for unknown PKCS11 return values, just use hex as its string
return "0x" + Functions.toFullHexString((int)errorCode);
// for unknown PKCS11 return values, use hex as its string
String res = "0x" + Functions.toFullHexString((int)errorCode);
// for vendor-defined values, check the enum for vendors and include
// potential matches
if ((errorCode & 0x80000000L) != 0) {
for (RV_VENDOR r : RV_VENDOR.values()) {
if (r.value == errorCode) {
res += "(" + r.name() + ")";
break;
}
}
}
return res;
}

/**
Expand Down