blob: b1ee3f8ae6d5081997817d628a6e954275a1af57 [file] [log] [blame]
Jeff Thompson8238d002013-07-10 11:56:49 -07001/**
2 * @author: Jeff Thompson
3 * Derived from PublisherPublicKeyDigest.js by Meki Cheraoui.
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "BinaryXML.h"
8#include "BinaryXMLPublisherPublicKeyDigest.h"
9
10ndn_Error ndn_encodeBinaryXMLPublisherPublicKeyDigest
11 (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXMLEncoder *encoder)
12{
13 if (!publisherPublicKeyDigest->publisherPublicKeyDigest || publisherPublicKeyDigest->publisherPublicKeyDigestLength == 0)
14 return;
15
16 ndn_Error error;
17 if (error = ndn_BinaryXMLEncoder_writeBlobDTagElement
18 (encoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, publisherPublicKeyDigest->publisherPublicKeyDigest,
19 publisherPublicKeyDigest->publisherPublicKeyDigestLength))
20 return error;
21
22 return 0;
23}
24
25ndn_Error ndn_decodeBinaryXMLPublisherPublicKeyDigest
26 (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXMLDecoder *decoder)
27{
28 ndn_Error error;
29 if (error = ndn_BinaryXMLDecoder_readBinaryDTagElement
30 (decoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, 0, &publisherPublicKeyDigest->publisherPublicKeyDigest,
31 &publisherPublicKeyDigest->publisherPublicKeyDigestLength))
32 return error;
33
34 return 0;
35}