|
@@ -120,9 +120,16 @@ UA_StatusCode
|
|
|
UA_SecureChannel_generateNonce(const UA_SecureChannel *const channel,
|
|
|
const size_t nonceLength,
|
|
|
UA_ByteString *const nonce) {
|
|
|
- UA_ByteString_allocBuffer(nonce, nonceLength);
|
|
|
- if(!nonce->data)
|
|
|
- return UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
+ if(channel == NULL || nonce == NULL)
|
|
|
+ return UA_STATUSCODE_BADINTERNALERROR;
|
|
|
+
|
|
|
+ if(nonceLength == 0)
|
|
|
+ return UA_STATUSCODE_GOOD;
|
|
|
+
|
|
|
+ UA_ByteString_deleteMembers(nonce);
|
|
|
+ UA_StatusCode retval = UA_ByteString_allocBuffer(nonce, nonceLength);
|
|
|
+ if(retval != UA_STATUSCODE_GOOD)
|
|
|
+ return retval;
|
|
|
|
|
|
return channel->securityPolicy->symmetricModule.generateNonce(channel->securityPolicy,
|
|
|
nonce);
|