Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ static P11Key derivePBEKey(Token token, PBEKeySpec keySpec, String algo)
}

if (kdfData.kdfMech == CKM_PKCS5_PBKD2) {
CK_VERSION p11Ver = token.p11.getInfo().cryptokiVersion;
if (P11Util.isNSS(token) || p11Ver.major < 2 ||
p11Ver.major == 2 && p11Ver.minor < 40) {
CK_INFO p11Info = token.p11.getInfo();
CK_VERSION p11Ver = (p11Info != null ? p11Info.cryptokiVersion
: null);
if (P11Util.isNSS(token) || p11Ver != null && (p11Ver.major <
2 || p11Ver.major == 2 && p11Ver.minor < 40)) {
// NSS keeps using the old structure beyond PKCS #11 v2.40
ckMech = new CK_MECHANISM(kdfData.kdfMech,
new CK_PKCS5_PBKD2_PARAMS(password, salt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void loadNative() {

private long pNativeData;

private CK_INFO pInfo;
private volatile CK_INFO pInfo;

/**
* This method does the initialization of the native library. It is called
Expand Down Expand Up @@ -153,7 +153,6 @@ public static void loadNative() {
throws IOException, PKCS11Exception {
connect(pkcs11ModulePath, functionListName);
this.pkcs11ModulePath = pkcs11ModulePath;
pInfo = C_GetInfo();
}

/*
Expand Down Expand Up @@ -215,7 +214,21 @@ public static synchronized PKCS11 getInstance(String pkcs11ModulePath,
* C_GetInfo. This structure represent Cryptoki library information.
*/
public CK_INFO getInfo() {
return pInfo;
CK_INFO lPInfo = pInfo;
if (lPInfo == null) {
synchronized (this) {
lPInfo = pInfo;
if (lPInfo == null) {
try {
lPInfo = C_GetInfo();
pInfo = lPInfo;
} catch (PKCS11Exception e) {
// Some PKCS #11 tokens require initialization first.
}
}
}
}
return lPInfo;
}

/**
Expand Down