Skip to content
Open
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
11 changes: 6 additions & 5 deletions ExportDSATest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@ public static void main(String[] args) throws Exception {
});

CK_ATTRIBUTE[] exportAttrs = {
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_DSA),
new CK_ATTRIBUTE(CKA_VALUE, new byte[0]),
new CK_ATTRIBUTE(CKA_PRIME, new byte[0]),
new CK_ATTRIBUTE(CKA_SUBPRIME, new byte[0]),
new CK_ATTRIBUTE(CKA_BASE, new byte[0])
};
p11.C_GetAttributeValue(session, keyId, exportAttrs);
assertEquals("Exported value", key.getX(), exportAttrs[1].getBigInteger());
assertEquals("Exported prime", key.getParams().getP(), exportAttrs[2].getBigInteger());
assertEquals("Exported subprime", key.getParams().getQ(), exportAttrs[3].getBigInteger());
assertEquals("Exported base", key.getParams().getG(), exportAttrs[4].getBigInteger());

int i = 0;
assertEquals("Exported value", key.getX(), exportAttrs[i++].getBigInteger());
assertEquals("Exported prime", key.getParams().getP(), exportAttrs[i++].getBigInteger());
assertEquals("Exported subprime", key.getParams().getQ(), exportAttrs[i++].getBigInteger());
assertEquals("Exported base", key.getParams().getG(), exportAttrs[i++].getBigInteger());

releaseSession(sunp11, session);
}
Expand Down
7 changes: 4 additions & 3 deletions ExportECTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ public static void main(String[] args) throws Exception {
});

CK_ATTRIBUTE[] exportAttrs = {
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_EC),
new CK_ATTRIBUTE(CKA_VALUE, new byte[0]),
new CK_ATTRIBUTE(CKA_EC_PARAMS, new byte[0])
};
p11.C_GetAttributeValue(session, keyId, exportAttrs);
assertEquals("Exported value", key.getS(), exportAttrs[1].getBigInteger());
assertEquals("Exported params", CurveDB.lookup(key.getParams()).getEncoded(), exportAttrs[2].getByteArray());

int i = 0;
assertEquals("Exported value", key.getS(), exportAttrs[i++].getBigInteger());
assertEquals("Exported params", CurveDB.lookup(key.getParams()).getEncoded(), exportAttrs[i++].getByteArray());

releaseSession(sunp11, session);
}
Expand Down
21 changes: 17 additions & 4 deletions ExportRSATest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,26 @@ public static void main(String[] args) throws Exception {
});

CK_ATTRIBUTE[] exportAttrs = {
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_RSA),
new CK_ATTRIBUTE(CKA_MODULUS, new byte[0]),
new CK_ATTRIBUTE(CKA_PRIVATE_EXPONENT, new byte[0])
new CK_ATTRIBUTE(CKA_PUBLIC_EXPONENT, new byte[0]),
new CK_ATTRIBUTE(CKA_PRIVATE_EXPONENT, new byte[0]),
new CK_ATTRIBUTE(CKA_PRIME_1, new byte[0]),
new CK_ATTRIBUTE(CKA_PRIME_2, new byte[0]),
new CK_ATTRIBUTE(CKA_EXPONENT_1, new byte[0]),
new CK_ATTRIBUTE(CKA_EXPONENT_2, new byte[0]),
new CK_ATTRIBUTE(CKA_COEFFICIENT, new byte[0]),
};
p11.C_GetAttributeValue(session, keyId, exportAttrs);
assertEquals("Exported modulus", key.getModulus(), exportAttrs[1].getBigInteger());
assertEquals("Exported private exponent", key.getPrivateExponent(), exportAttrs[2].getBigInteger());

int i = 0;
assertEquals("Exported modulus", key.getModulus(), exportAttrs[i++].getBigInteger());
assertEquals("Exported public exponent", key.getPublicExponent(), exportAttrs[i++].getBigInteger());
assertEquals("Exported private exponent", key.getPrivateExponent(), exportAttrs[i++].getBigInteger());
assertEquals("Exported prime P", key.getPrimeP(), exportAttrs[i++].getBigInteger());
assertEquals("Exported prime Q", key.getPrimeQ(), exportAttrs[i++].getBigInteger());
assertEquals("Exported prime exponent P", key.getPrimeExponentP(), exportAttrs[i++].getBigInteger());
assertEquals("Exported prime exponent Q", key.getPrimeExponentQ(), exportAttrs[i++].getBigInteger());
assertEquals("Exported coefficient", key.getCrtCoefficient(), exportAttrs[i++].getBigInteger());

releaseSession(sunp11, session);
}
Expand Down