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 1059705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:12:53+00:00 2026-05-16T18:12:53+00:00

INITIAL NOTE: This is just for a personal tinkering project; I’m not writing enterprise

  • 0

INITIAL NOTE: This is just for a personal tinkering project; I’m not writing enterprise security here, and if I were, I’d know better than to try to write my own scheme. 😀

EDIT: To stress the above point, I tried to tag this under “iKnowThisWouldBeABadIdeaInRealLife”, but SO wouldn’t accept it because it was >25 chars. Just be aware that I KNOW it’s not commercial grade!

I need a way to authenticate a user over HTTP (can’t use HTTPS in this case). I need to know that the person on the other end really is who they say they are (to some reasonably high degree of confidence). Once I’m sure the user is legit, I do not care if the content between the client and the server are sent as plaintext.

The trouble I’m looking at is in trying to send a password from the client to the server without sending it as plaintext. I’ve thought about trying some public-key crypto in javascript, since some Google searching has turned up some fun-looking libraries.

Here’s the scheme I’m thinking about:

(suppose A and A’ represent the private and public keys, respectively; also, enc(text, key) and dec(cyphertext, key) represent the encryption/decryption functions)

    +------------------------+------------------------------+
    |         SERVER         |            CLIENT            |
    +------------------------+------------------------------+
(1) | t = randomToken()      |                              |
(2) | enc(t, A)           -------->  c                      |
(3) |                        |       A' = getKeyFromUser()  |
(4) | p                 <--------    p=dec(c, A')           |
(5) | if (t==p)              |                              |
    |     allowAccess()      |                              |
    | else                   |                              |
    |     denyAccess()       |                              |
    +------------------------+------------------------------+

One weakness I see in this is that the BAD GUY who was listening to the exchange, while he doesn’t have A, now has a known ciphertext/plaintext combo, which I remember from crypto class is a BAD IDEA. I figure some salting could alleviate this somehow?

So here are my [two] questions:

  1. Is this a ‘good’ scheme? (remember that I don’t CARE if anything following this initial exchange is plaintext – I’m ONLY trying to verify initial identity here)
  2. What would be the best way to get around the “known plaintext/cyphertext pair” weakness mentioned above? Salting?

Thanks!


EDIT: Thanks for all the discussion! Just to clarify:

  • I’m NOT worried about assuring the CLIENT that the SERVER is who they say they are. Only the opposite (assuring the SERVER the CLIENT is who they say they are)
  • I know about MITM attacks. This scheme is NOT intended to protect against them.
  • I know there exist plenty of solutions for this already. This is purely a learning exercise for me! I’m not trying to re-invent the wheel or build a better mousetrap. This is just for fun!
  • Here was my thought-process for the scheme: (I know I’m not quite using public vs. private keys properly, but bear with me for a sec)

    • Bob walks up to Alice and says, “Hey, I’m Bob.”

    • Alice says, “Okay. I know Bob’s ‘private key’. If you’re really Bob, take this secret message I just encrypted (with Bob’s private key), and decrypt it for me.”

    • Bob replies with the correct message, and Alice is happy.

  • 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-16T18:12:54+00:00Added an answer on May 16, 2026 at 6:12 pm

    You basically want to implement SSL on HTTP; which is somewhat feasible, but will never be as good as the real thing.

    Being able to send encrypted data back and forth is only half the problem. Another part of the problem is ensuring you are actually talking to the server (think of man in the middle attacks).

    I am not really sure how the SSL works, but that is the way to go. You should read up on that. From the looks of your scheme, it seems totally pointless however. Why are you sending plaintext back to the server? That defeats the purpose of having this set up.

    Here’s how I would do this:

    1. Server sends a random token to the client. Server stores the token in a “pending” list. These can be purged in some interval (eg: every 15 minutes)
    2. Client sends enc(comb(username, password, token), pubKey) back to the server, where comb() is some function that combines the username, password and the random token.
    3. Server gets the username and password back using decomb(dec(message, privKey)) where decomb() is the inverse of comb().
    4. Server checks if the token is present in the pending list. If it’s not, reject the login attempt. If it is, it server can proceed to perform authentication as usual.

    If the generated tokens are never repeated, an attacker can’t just re-send the same encrypted message, nor can they decrypt the message to find out what everything was.

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

Sidebar

Related Questions

NOTE: This is a solution for Project Euler Problem 14 . If you still
When prototyping initial GUI functionality with a customer is it better to use a
During our initial development we haven't worried about scaling concerns, just getting the bare
I know how to fill an std::vector with non-trivial initial values, e.g. sequence numbers:
(Note: This is an extension of a previous question .) I am having some
ModelMultipleChoiceField doesn't select initial choices and I can't make the following fix (link below)
How would I change the initial templates created by Xcode when creating a new
How do I set the initial width of a QDockWidget? I have implemented the
I would like to set some initial variables (like format compact and the current
Is there a way to set the initial path for the FileUpload widget in

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.