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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:28:42+00:00 2026-06-06T18:28:42+00:00

Bouncy castle already provide XTEA encryption using class XTEAEngine. The class attributes look like

  • 0

Bouncy castle already provide XTEA encryption using class XTEAEngine.
The class attributes look like this:

private static final int rounds     = 32,
                         block_size = 8,
                         key_size   = 16,
                         delta      = 0x9E3779B9,
                         d_sum      = 0xC6EF3720; // sum on decrypt

But closed source C++ application uses following settings (with 32 rounds):

uint32 delta = 0x61C88647;
uint32 sum = 0xC6EF3720;

So to change it, I’ve copied whole code of BC XTEAEngine class, named it XTEAEngine2 at changed delta. But now encryption does not work as expected:

arr given    : [11, 0, 10, 8, 0, 72, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0] 
arr encrypted: [-128, -26, -32, 17, 7, 98, 80, -112, 26, -83, -11, 47, -124, -50, -80, 59] 
arr decrypted: [-106, 62, 110, -40, -56, -58, 18, -101, -38, -73, -83, 95, 18, -99, -84, -37]

Before my change everything was fine:

arr given    : [11, 0, 10, 8, 0, 72, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0]
arr encrypted: [89, -95, -88, 120, -117, 39, 57, -126, 23, -74, 35, 105, -23, -7, -109, -27]
arr decrypted: [11, 0, 10, 8, 0, 72, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0]

And I’m using BouncyCastle XTEA like this:

BlockCipher engine = new XTEAEngine[2]();
BufferedBlockCipher cipher = new BufferedBlockCipher(engine);
KeyParameter kp = new KeyParameter(keyArr);
 private byte[] callCipher( byte[] data )
    throws CryptoException {
        int    size =
                cipher.getOutputSize( data.length );
        byte[] result = new byte[ size ];
        int    olen = cipher.processBytes( data, 0,
                data.length, result, 0 );
        olen += cipher.doFinal( result, olen );

        if( olen < size ){
            byte[] tmp = new byte[ olen ];
            System.arraycopy(
                    result, 0, tmp, 0, olen );
            result = tmp;
        }

        return result;
    }


public synchronized byte[] encrypt( byte[] data )
    throws CryptoException {
        if( data == null || data.length == 0 ){
            return new byte[0];
        }

        cipher.init( true, kp );
        return callCipher( data );
    }

    public synchronized byte[] decrypt( byte[] data )
    throws CryptoException {
        if( data == null || data.length == 0 ){
            return new byte[0];
        }

        cipher.init( false, kp );
        return callCipher( data );
    }

Is anyone able to point my mistake? Because I believe that I made one somewhere.
I even implemented XTEA completely on my own using algorithm specification from Wikipedia but same thing happened.

  • 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-06-06T18:28:43+00:00Added an answer on June 6, 2026 at 6:28 pm

    0x9E3779B9 is the two’s complement negative of 0x61C88647; this suggests to me that there’s an addition vs a subtraction swapped somewhere.

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

Sidebar

Related Questions

I am doing encryption and decryption using AES Algorithm with bouncy castle My encryption
I am using Bouncy Castle provided library to encrypt,decrypt,sign and verify sign. I am
How do I implement AES encryption with the java bouncy castle library? Example code
How do encrypt/decrypt a long or int using the Bouncy Castle crypto routines for
Surprisingly enough there's very little information on the Web about using Bouncy Castle's lightweight
I need help using Bouncy Castle RSA Libraries for a school assignment, but it
I'm using Bouncy Castle (c#/vb.net version) and generating a 4096-byte RSA Keypair to use
I have added the bouncy castle jar file to my application class path in
I am trying to decrypt data that is encrypted using the Bouncy Castle library
I have an Android crypto app that's built with Bouncy Castle (actually using Spongy

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.