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

  • SEARCH
  • Home
  • 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 4324420
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:07:48+00:00 2026-05-21T09:07:48+00:00

I am writing an application that heavily uses cryptology. Like most networked applications, mine

  • 0

I am writing an application that heavily uses cryptology. Like most networked applications, mine breaks up data into different types of messages (instant message, file chunk, video frame, etc.) — and each one must be checked for authenticity both for anti-tampering and correct origin. So far, I am able to use ECDH to negotiate a shared secret which I use already for AES. Of course, that same shared secret can be used later.

My question is: In this case, is there any added benefit to using ECDSA in order to sign each message, rather than simply using the shared secret established by ECDH with a HMAC?

Below, when I say M, I mean either an encrypted message or plaintext; it shouldn’t matter. Please correct any errors below.

I understand that in ECDSA (or DSA) typically hashes a message (M) with a secure hashing algorithm (I am currently using one of the SHA-2s) to make H(M), then encrypts the H(M) using the signer’s private key. This produces R and S integers (the signature). Then, M, R and S are sent to the recipient, who is already in possession of the sender’s public key. H'(M) is calculated, and the signature is verified using R and S. BouncyCastle provides ECDSASigner which implements this.

In HMAC, a shared secret is required, which I have. Then:
HMAC(K, M) := H( f2(K) || H(f1(K) || M) )
(Thanks for the correction, Paŭlo Ebermann. See his answer for details.)

So, considering that DH/ECDH negotiate a shared secret securely, is there a reason I shouldn’t use HMAC?

Related: why does the NSA specify a standard algorithm for DSA and not MAC? Just because it can be SHA-2 + AES?

Speed is important here because I want this one protocol that I’m making to support not only text messages now, but also large files and video frames in the near future. Therefore I prefer using an HMAC but want to make sure I can meet the goals above.

Thanks for your help!

  • 1 1 Answer
  • 3 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-21T09:07:48+00:00Added an answer on May 21, 2026 at 9:07 am

    One disadvantage of DSA is that you need quite some good random bytes for your signature. It is even the case that using a bad random source your private key can be reconstructed from the signature. For a MAC, you have to sign lots of messages, so you need lots of random numbers. If you have no hardware producing these, you will run out of entropy.

    HMAC does not need any random numbers (it is deterministic).

    Additionally I think HMAC will be more efficient than using DSA here, but you could (and should) measure this.


    About "correct errors": Your description of HMAC is not quite right – there is no "decryption". It is more like this:

    You have the message M, a hash function H, and a shared secret K. Add two public functions f1 and f2 (these are some simple XOR+padding). Then

    HMAC(K, M) := H( f2(K) || H(f1(K) || M) )
    

    with || being simple concatenation. The sender and receiver do the same calculation, the sender sends his one with the message, and the receiver then compares his result with the sent one. (Make sure you do your comparison in a way which does not allow timing attacks, i.e. compare everything, even if you already found it does not match.)

    The exact definition of HMAC is in RFC 2104, which also contains some clarifying figures.


    About this question:

    Related: why does the NSA specify a standard algorithm for DSA and not MAC?

    I’m not really sure, but here is one idea:

    The list of links there mentions the "Galois Counter Mode" for TLS (RFC 5288) and SSH (RFC 5647), and this is said to protect both confidentiality and integrity in one. Thus a separate MAC is not necessary anymore. (It’s the first time I read this, so I can’t judge this right now.)

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

Sidebar

Related Questions

I'm writing an application that uses Apple's kiosk mode. I would like to disable
I'm currently writing a Java application that needs to look at how heavily loaded
I'm writing an application that loads some javascript into a WebBrowser object. To prevent
I am writing an application that is accepting POST data from a third party
I'm writing an application that uses extendable UI elements, whose precise implementation is determined
I writing an application that is running in 3.1, that uses an ActionBar with
I'm writing an application that manages something like Drupal's nodes. I'm planning on using
I'm writing an application that uses the phone's camera to take a picture, and
I am writing an application that uses SSLEngine with NIO, I writing both the
I am writing an application that will move data from one database to another

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.