Skip to content

Commit 18930dd

Browse files
committed
SANTUARIO-491 - Default KeyInfo resolver doesn't check for empty element content.
1 parent 722abd4 commit 18930dd

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

xsec/dsig/DSIGKeyInfoValue.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,71 +109,71 @@ class XSEC_EXPORT DSIGKeyInfoValue : public DSIGKeyInfo {
109109
* a DOM structure
110110
*/
111111

112-
virtual void load(void);
112+
virtual void load();
113113

114114
/**
115115
* \brief Get P value
116116
*
117117
* @returns a pointer to the DSA P string value.
118118
*/
119119

120-
const XMLCh * getDSAP(void) const {return mp_PTextNode->getNodeValue();}
120+
const XMLCh * getDSAP() const {return mp_PTextNode ? mp_PTextNode->getNodeValue() : NULL;}
121121

122122
/**
123123
* \brief Get Q value
124124
*
125125
* @returns a pointer to the DSA Q string value.
126126
*/
127127

128-
const XMLCh * getDSAQ(void) const {return mp_QTextNode->getNodeValue();}
128+
const XMLCh * getDSAQ() const {return mp_QTextNode ? mp_QTextNode->getNodeValue() : NULL;}
129129

130130
/**
131131
* \brief Get G value
132132
*
133133
* @returns a pointer to the DSA G string value.
134134
*/
135135

136-
const XMLCh * getDSAG(void) const {return mp_GTextNode->getNodeValue();}
136+
const XMLCh * getDSAG() const {return mp_GTextNode ? mp_GTextNode->getNodeValue() : NULL;}
137137

138138
/**
139139
* \brief Get Y value
140140
*
141141
* @returns a pointer to the DSA Y string value.
142142
*/
143143

144-
const XMLCh * getDSAY(void) const {return mp_YTextNode->getNodeValue();}
144+
const XMLCh * getDSAY() const {return mp_YTextNode ? mp_YTextNode->getNodeValue() : NULL;}
145145

146146
/**
147147
* \brief Get Modulus
148148
*
149149
* @returns A pointer to the RSA Modulus
150150
*/
151151

152-
const XMLCh * getRSAModulus(void) const;
152+
const XMLCh * getRSAModulus() const;
153153

154154
/**
155155
* \brief Get Exponent
156156
*
157157
* @returns A pointer to the buffer containing the RSA Modulus string
158158
*/
159159

160-
const XMLCh * getRSAExponent(void) const;
160+
const XMLCh * getRSAExponent() const;
161161

162162
/**
163163
* \brief Get NamedCurve URI
164164
*
165165
* @returns A pointer to the EC NamedCurve URI
166166
*/
167167

168-
const XMLCh * getECNamedCurve(void) const;
168+
const XMLCh * getECNamedCurve() const;
169169

170170
/**
171171
* \brief Get EC Public Key
172172
*
173173
* @returns A pointer to the buffer containing the EC public key
174174
*/
175175

176-
const XMLCh * getECPublicKey(void) const;
176+
const XMLCh * getECPublicKey() const;
177177

178178
//@}
179179

xsec/enc/XSECKeyInfoResolverDefault.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,29 @@ XSECCryptoKey* XSECKeyInfoResolverDefault::resolveKey(const DSIGKeyInfoList* lst
103103
{
104104

105105
const DSIGKeyInfoValue* dsaval = (const DSIGKeyInfoValue *) lst->item(i);
106-
if (dsaval->getDSAP() && dsaval->getDSAQ() && dsaval->getDSAG() && dsaval->getDSAY()) {
106+
if (dsaval->getDSAP() || dsaval->getDSAQ() || dsaval->getDSAG() || dsaval->getDSAY()) {
107107

108108
XSECCryptoKeyDSA * dsa = XSECPlatformUtils::g_cryptoProvider->keyDSA();
109109
Janitor<XSECCryptoKeyDSA> j_dsa(dsa);
110110

111111
safeBuffer value;
112112

113-
value << (*mp_formatter << dsaval->getDSAP());
114-
dsa->loadPBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
115-
value << (*mp_formatter << dsaval->getDSAQ());
116-
dsa->loadQBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
117-
value << (*mp_formatter << dsaval->getDSAG());
118-
dsa->loadGBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
119-
value << (*mp_formatter << dsaval->getDSAY());
120-
dsa->loadYBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
113+
if (dsaval->getDSAP()) {
114+
value << (*mp_formatter << dsaval->getDSAP());
115+
dsa->loadPBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
116+
}
117+
if (dsaval->getDSAQ()) {
118+
value << (*mp_formatter << dsaval->getDSAQ());
119+
dsa->loadQBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
120+
}
121+
if (dsaval->getDSAG()) {
122+
value << (*mp_formatter << dsaval->getDSAG());
123+
dsa->loadGBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
124+
}
125+
if (dsaval->getDSAY()) {
126+
value << (*mp_formatter << dsaval->getDSAY());
127+
dsa->loadYBase64BigNums(value.rawCharBuffer(), (unsigned int) strlen(value.rawCharBuffer()));
128+
}
121129

122130
j_dsa.release();
123131
return dsa;

0 commit comments

Comments
 (0)