Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 295505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:27:51+00:00 2026-05-12T06:27:51+00:00

I have an edge case. I’m building code that reads binary datafiles produced by

  • 0

I have an edge case. I’m building code that reads binary datafiles produced by a commercial, closed source tool. The information on the data format is specified in a document.

For data integrity checks, the vendor’s spec calls for an HMAC based on SHA1, using a key derived from a password as per RFC2898. Many programming environments have a class called HMACSHA1 to produce these hashes.

For data streams of non-zero length, I can successfully calculate the Hash, and the calculation in my code agrees with the vendor’s implementation. In other words, my code can read and authenticate files written by the vendor, and vice versa.

However, when the length of the data stream is zero, the vendor’s tool emits a Hash which is NOT all zeroes. I don’t know where it comes from, if there is no message to run through the HMACSHA1.

For HMACSHA1, or for any HMAC, is the MAC defined for the edge case of “a null message”?

I am using .NET, and the class System.Security.Cryptography.HMACSHA1, although I believe my question is platform-agnostic.


There is one platform-specific bit: When I try to get the Hash property on an instance of that type, if I have not run any data through the instance, I get

Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Security.Cryptography.HashAlgorithm.get_Hash()

This isn’t surprising to me at all, since there is nothing to hash.

any hints?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:27:51+00:00Added an answer on May 12, 2026 at 6:27 am

    Bumbling around in the dark, I found what I needed.
    Not sure if HMACSHA1 is defined for the case of a zero-length message, BUT

    I did find that on .NET, if I call HMACSHA1.ComputeHash() and pass a byte array of length zero, I get the expected, desired hash.

    Sorry for the noise, we now return you to your previously scheduled programming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 206k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The stack trace is created when the exception is instantiated,… May 12, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer Yes they are.. for jQuery there is even special plugin… May 12, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer To provide a default value (used when the target of… May 12, 2026 at 9:16 pm

Related Questions

I have an edge case. I'm building code that reads binary datafiles produced by
I have an odd edge case right now in that a response code from
I have a winform program that uses Merge Replication to keep a local SQL
I am using hudson CI to manage a straight java web project, using ant
Posting a stack overflow question on stackoverflow.com, how amusing :-) I'm running some recursive

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.