summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristina Fu <cfu@redhat.com>2013-01-26 03:39:24 -0800
committerChristina Fu <cfu@redhat.com>2013-01-26 03:39:24 -0800
commit95e41dc9043a3fbbeea2abd58cca84d1442c0102 (patch)
treea795bbb7e6bafb51980d309d7eb635442276e4df
parent833feccb5539146a7f7288ed7eaef5aed9f26911 (diff)
downloadpki-95e41dc9043a3fbbeea2abd58cca84d1442c0102.zip
pki-95e41dc9043a3fbbeea2abd58cca84d1442c0102.tar.gz
pki-95e41dc9043a3fbbeea2abd58cca84d1442c0102.tar.xz
Bug 903401 - TMS: RSA token enrollment failed : public key decode error
-rw-r--r--base/kra/src/com/netscape/kra/NetkeyKeygenService.java10
-rw-r--r--base/tps/src/processor/RA_Enroll_Processor.cpp24
2 files changed, 22 insertions, 12 deletions
diff --git a/base/kra/src/com/netscape/kra/NetkeyKeygenService.java b/base/kra/src/com/netscape/kra/NetkeyKeygenService.java
index f0eec6a..3acea9a 100644
--- a/base/kra/src/com/netscape/kra/NetkeyKeygenService.java
+++ b/base/kra/src/com/netscape/kra/NetkeyKeygenService.java
@@ -486,9 +486,13 @@ public class NetkeyKeygenService implements IService {
return false;
} else {
//CMS.debug("NetkeyKeygenService: public key binary length ="+ publicKeyData.length);
- /* url encode */
- PubKey = com.netscape.cmsutil.util.Utils.SpecialEncode(publicKeyData);
- CMS.debug("NetkeyKeygenService: EC PubKey special encoded");
+ if (rKeytype.equals("EC")) {
+ /* url encode */
+ PubKey = com.netscape.cmsutil.util.Utils.SpecialEncode(publicKeyData);
+ CMS.debug("NetkeyKeygenService: EC PubKey special encoded");
+ } else {
+ PubKey = base64Encode(publicKeyData);
+ }
//CMS.debug("NetkeyKeygenService: public key length =" + PubKey.length());
request.setExtData("public_key", PubKey);
diff --git a/base/tps/src/processor/RA_Enroll_Processor.cpp b/base/tps/src/processor/RA_Enroll_Processor.cpp
index 6922dc2..e4ff38c 100644
--- a/base/tps/src/processor/RA_Enroll_Processor.cpp
+++ b/base/tps/src/processor/RA_Enroll_Processor.cpp
@@ -363,19 +363,25 @@ RA_Status RA_Enroll_Processor::DoEnrollment(AuthParams *login, RA_Session *sessi
SECItem der;
CERTSubjectPublicKeyInfo* spki = NULL;
- Buffer *decodePubKey = Util::URLDecode(pKey);
- char *pKey_ascii = NULL;
- if (decodePubKey != NULL) {
- pKey_ascii =
- BTOA_DataToAscii(decodePubKey->getBuf(), decodePubKey->size());
+ if (isECC) {
+ Buffer *decodePubKey = Util::URLDecode(pKey);
+ char *pKey_ascii = NULL;
+ if (decodePubKey != NULL) {
+ pKey_ascii =
+ BTOA_DataToAscii(decodePubKey->getBuf(), decodePubKey->size());
+ } else {
+ PR_snprintf(audit_msg, 512, "ServerSideKeyGen: failed to URL decode public key");
+ goto loser;
+ }
+
+ der.type = (SECItemType) 0; /* initialize it, since convertAsciiToItem does not set it */
+ rv = ATOB_ConvertAsciiToItem (&der, pKey_ascii);
} else {
- PR_snprintf(audit_msg, 512, "ServerSideKeyGen: failed to URL decode public key");
- goto loser;
+ der.type = (SECItemType) 0; /* initialize it, since convertAsciiToItem does not set it */
+ rv = ATOB_ConvertAsciiToItem (&der, pKey);
}
- der.type = (SECItemType) 0; /* initialize it, since convertAsciiToItem does not set it */
- rv = ATOB_ConvertAsciiToItem (&der, pKey_ascii);
if (rv != SECSuccess){
RA::Debug(LL_PER_CONNECTION,FN,
"failed to convert b64 public key to binary");