Exemplo n.º 1
0
void
DigestSha256Signature::get(struct ndn_Signature& signatureStruct) const
{
  // Initialize unused fields.
  ndn_Signature_clear(&signatureStruct);

  signatureStruct.type = ndn_SignatureType_DigestSha256Signature;
  signature_.get(signatureStruct.signature);
}
Exemplo n.º 2
0
ndn_Error
ndn_decodeTlvSignatureInfo
(struct ndn_Signature *signatureInfo, struct ndn_TlvDecoder *decoder)
{
    ndn_Error error;
    size_t beginOffset;
    size_t endOffset;
    uint64_t signatureType;
    int gotExpectedType;

    ndn_Signature_clear(signatureInfo);

    beginOffset = decoder->offset;
    if ((error = ndn_TlvDecoder_readNestedTlvsStart
                 (decoder, ndn_Tlv_SignatureInfo, &endOffset)))
        return error;

    if ((error = ndn_TlvDecoder_readNonNegativeIntegerTlv
                 (decoder, ndn_Tlv_SignatureType, &signatureType)))
        return error;

    if (signatureType == ndn_Tlv_SignatureType_SignatureSha256WithRsa ||
            signatureType == ndn_Tlv_SignatureType_SignatureSha256WithEcdsa ||
            signatureType == ndn_Tlv_SignatureType_SignatureHmacWithSha256) {
        // Assume that the ndn_SignatureType enum has the same values as the TLV
        // signature types.
        signatureInfo->type = signatureType;
        if ((error = ndn_decodeTlvKeyLocator
                     (ndn_Tlv_KeyLocator, &signatureInfo->keyLocator, decoder)))
            return error;
        if ((error = ndn_TlvDecoder_peekType
                     (decoder, ndn_Tlv_ValidityPeriod_ValidityPeriod, endOffset,
                      &gotExpectedType)))
            return error;
        if (gotExpectedType) {
            if ((error = decodeValidityPeriod(&signatureInfo->validityPeriod, decoder)))
                return error;
        }
    }
    else if (signatureType == ndn_Tlv_SignatureType_DigestSha256)
        signatureInfo->type = ndn_SignatureType_DigestSha256Signature;
    else {
        signatureInfo->type = ndn_SignatureType_Generic;
        signatureInfo->genericTypeCode = signatureType;

        // Get the bytes of the SignatureInfo TLV.
        if ((error = ndn_TlvDecoder_getSlice
                     (decoder, beginOffset, endOffset, &signatureInfo->signatureInfoEncoding)))
            return error;
    }

    if ((error = ndn_TlvDecoder_finishNestedTlvs(decoder, endOffset)))
        return error;

    return NDN_ERROR_success;
}
Exemplo n.º 3
0
void
SignatureLite::clear() { ndn_Signature_clear(this); }