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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:05:23+00:00 2026-05-15T10:05:23+00:00

Well, I’ve been going through my personal hell these days I am having some

  • 0

Well, I’ve been going through my personal hell these days

I am having some trouble decrypting a message that was encrypted using
RSA and I’m always failing with a “RSA/OAEP-MGF1(SHA-1): invalid
ciphertext”

  1. I have a private key encoded in base64 and I load it:

        RSA::PrivateKey private_key;
        StringSource file_pk(PK,true,new Base64Decoder);
        private_key.Load( file_pk );
    
  2. I then proceed to decode the message by doing:

    RSAES_OAEP_SHA_Decryptor decryptor(private_key);
    
    AutoSeededRandomPool rng;
    
    string result;
    StringSource(ciphertext, true,
        new PK_DecryptorFilter(rng, decryptor,
            new StringSink(result)
        )
    );
    

As far as I can tell, the message should be being parsed without any
problems. ciphertext is an std::string, so no \0 at the end that could
do something unexpected.

I just though of something, and what if the private key is incorrect
but can be loaded anyway without throwing a BER decode error. What
would that throw when decrypting?

Hope that anyone can shed some light on this.

Cheers

  • 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-15T10:05:23+00:00Added an answer on May 15, 2026 at 10:05 am

    If the key was actually corrupted, the Load function should have failed. However you can ask the key to self-test itself, which should detect any corruption, by calling Validate, like:

    bool key_ok = private_key.Validate(rng, 3);
    

    The second parameter (here, 3) specifies how much checking to be done. For RSA, this will cause it to run all available tests, even the slow/expensive ones.

    Another reason the decoding might fail is if the key simply is not the one that was used to encrypt the original message.

    Obviously the ciphertext input must be completely identical to what was originally produced on the encrypting side. For debugging, one good way to check this would be to feed the ciphertext at both sides into a hash function (conveniently already available to you, of course) and comparing the outputs. If you hex or base64 encoded the ciphertext for transmission you must undo that before you give it to the RSA decryptor.

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

Sidebar

Related Questions

Well, having decided to get to know some of the basic functions in R
Well I have a view of this type of hierarchy Main View (having some
Well, I have a application which somehow requires some system resources, but how do
Well after much messing about I have finally got a query that gives sales
Well, I am storing variables inside of a class that will be used for
well i have used an html file like these in iframe <iframe src=sample.html></iframe> is
Well im here because i have a problem. i have code that was created
Well, I have to revive a question that was answered here before. I've made
Well, that might be a strange question, and maybe just because I'm not familiar
Well, I believe the title is pretty straight forward. I've read many times that

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.