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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:39:20+00:00 2026-05-31T21:39:20+00:00

I have some data from a external party which is encrypted according to them

  • 0

I have some data from a external party which is encrypted according to them in: ‘Rijndeal 256 with the private key’

Alongside these records there are a public and private key certificate which look like RSA certificates.

From what i’ve learned so far it seems the common way to use encryption with certifcates is to generate a ‘secret key’ or some kind in initialization vector and use this to encrypted text. So i’m thinking this is probably what they have done (the data was encrypted by a PHP application)

I’m trying to decrypt this text with javax.crypto.Cipher but i think i problably need more information on the specific encryption, but i dont really know what information to ask for, and think its likely the ‘default options’ will probably work. (Communication with the supplying party is difficult and slow).

i’m currently Using the following code to get the private key:

  InputStreamReader ir = new InputStreamReader(the_inputstream_for_the_private_key_record);
   Security.addProvider(new BouncyCastleProvider());
   pemr = new PEMReader(ir);
   Object o = pemr.readObject();
   keyPair kp = (KeyPair) o;
   return kp.getPrivate();

This seems to work as i get a instantiated PrivateKey object without errors the toString looks like:

RSA Private CRT Key
            modulus: c98faa50ba69<trimmed>
    public exponent: 10001
   private exponent: bb889fbe5cb2a6763f...<trimmed>
             primeP: eb73e85dc636f5751b...<trimmed>
             primeQ: db269bd603a2b81fc9...<trimmed>
     primeExponentP: 85b9f111c190595cc8...<trimmed>
     primeExponentQ: a66d59a75bb77530de...<trimmed>
     crtCoefficient: 79415b078c4c229746...<trimmed>

For each record i also have a entry like the following:

{
"decryptedLength":128389,
"symKeyLength":32,
"symKey":"SImE8VnSZaAu1Ve...<trimmed (this is always 685 chars long) >...ayaJcnpSeOqAGM7q="
}

Basically this is where i’m a bit stuck.
My guess would be that that ‘symkey’ value is encrypted with RSA which in turn when decrypted would yield the secretKey for the AES part, but if i try:

Cipher rsaCipher = Cipher.getInstance("RSA");
rsaCipher.init(Cipher.DECRYPT_MODE, key);
byte[] b = rsaCipher.doFinal('symkey'.getbytes());

this gets me “javax.crypto.IllegalBlockSizeException: Data must not be longer than 512 bytes”, which seems logical since this string is 685characters long

I’m probably missing something very obvious here…
Any suggestions are appreciated.

  • 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-31T21:39:21+00:00Added an answer on May 31, 2026 at 9:39 pm

    with GregS’s answer i finaly got this to work.
    (adding an answer in case someone else needs to decrypt similar php encoded stuff).

    The first part was to decrypt de symmetricKey (“symkey”) from the metaData string
    This was as Greg notes a Base64 encoded, RSA encrypted key which was decoded like so:

    Cipher rsaCipher = Cipher.getInstance("RSA");
    rsaCipher.init(Cipher.DECRYPT_MODE, key);
    byte[] encryptedRijndaelKey = Base64.decodeBase64(base64EncodedSymetricKey); //from the metaData
    byte[] rijndaelKeyBytes = rsaCipher.doFinal(encryptedRijndaelKey);
    

    This Rijndael key was then used to decrypt de actual encrypted data like so:

    RijndaelEngine rijndaelEngine = new RijndaelEngine(256); // *1 *2
    KeyParameter keyParam = new KeyParameter(rijndaelKeyBytes)
    rijndaelEngine.init(false, keyParam);  //false == decrypt
    PaddedBufferedBlockCipher bbc = new PaddedBufferedBlockCipher(rijndaelEngine, new ZeroBytePadding()); // *3 
    
    byte[] decryptedBytes = new byte[decryptedLenght]; //from the storageOptions string
    int processed = bbc.processBytes(inputBytes, 0, inputBytes.length, decryptedBytes, 0);
    bbc.doFinal(decryptedBytes, processed);
    

    *1 because the Sun JCA only supports common AES which has a 128bits keysize i had to use a different provider (BouncyCastle).
    *2 apparently the blocksize was also 256 bits (trail & error)
    *3 apparently there was no padding used, thus the ZeroPadding for padding (again trail & error).

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

Sidebar

Related Questions

I have an Android application which grabs some data from an external XML source.
I have to insert some data from external source. My php function runs periodically
I have some decimal data coming from an external service. I need to format
I have some data from JQGrid that should be exported to excel. So, we
I have some data, yes, data. This data came from a MySQL query and
I'm using Selenium for work and I have extract some data from //ul, unfortunately
I have some data that comes regularily as a dump from a data souce
We have recently moved some data from an SQL Database instance to another one
I have some existing code that retrieves data from a database using ADO.NET that
We have some C# code that reads data from a text file using a

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.