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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:31:57+00:00 2026-06-09T00:31:57+00:00

I am lost in the underworld of pointers! Here is my problem, It is

  • 0

I am lost in the underworld of pointers! Here is my problem,

It is very quirky and I can only control one of the functions so please don’t say I need to redesign.
This is being compiled in Linux Ubuntu 11.04 using android-ndkr7. It is a purely native application (or service) that will run on an android phone. I am using google test to verify my class/functions.
The first function (my test class) has to declare the unsigned char*, it passes it to the 2nd function to be used as output (crypt::encryptBuffer), encrypt takes the declared variable, allocates memory for it and passes it to a third function which is where the value is being placed into it as output.

Crypt.h

class Crypt
{
public:

   Crypt();
   ~Crypt();

   bool encryptBuffer(const unsigned char* inDecryptBuffer, const int inputSize, unsigned char** outEncryptBuffer, int*  pOutSize);

};

#endif

Crypt.cpp

#include "Crypt.h"
#include "pan/crypt.h"

static unsigned char HydraEncryptionKey[] = {0x17, 0x43, 0x9B, 0x55, 0x07, 0xAE, 0x73, 0xB1, 0x32, 0x10, 0xE0, 0x22, 0xD9, 0xC7, 0xF2, 0x3B};

bool AccCrypt::encryptBuffer(const unsigned char* inDecryptBuffer, const int inputSize, unsigned char** outEncryptBuffer, int*  pOutSize)
{
    int encryptedSize;
    pan::aes128_cbc enc(HydraEncryptionKey);

    // see how long the encrypted data will be and allocate space for the data
    encryptedSize = enc.output_len( inputSize );

    *outEncryptBuffer = (unsigned char*)malloc(encryptedSize + 4);

    enc.encrypt(inDecryptBuffer, *outEncryptBuffer, inputSize );
    return true;
}

CryptTest.cpp

#incude "Crypt.h"
#include <gtest/gtest.h>

#define CHECK_COND(X, a, b, c) { \
if(X) \
{ \
    printf("FAIL: %s\n", c); \
    printf("Press any key to continue");\
    getc(stdin);\
}\
else \
{ \
    printf("PASS: %s\n", c); \
}\
}

#define EXPECT_EQ(a,b,c)  CHECK_COND((a != b), a, b, c)

const char* decBuff = "something";
const int inputSize = 10;
unsigned char* encBuffTest = NULL;
int pOutsize = 0;

class cryptTester : public testing::Test
{
    protected:
    virtual void SetUp()
    {
        cryptTest = new Crypt();
        cryptTest->encryptBuffer((const unsigned char*)decBuff, inputSize, &encBuffTest, &pOutsize);
    }

    virtual void TearDown()
    {
    }

    Crypt* cryptTest;

};
TEST_F(AccCryptTest, decryptBuffer)
{
    int poutSize = 0;
    EXPECT_EQ(true, accCryptTest->decryptBuffer((const unsigned char*)encBuffTest, pOutsize, &outDecryptBuffTest, &poutSize), "decryptBuffer(valid, valid)");

}

This will compile fine, however when I run it on the phone I get a segmentation fault. I cannot figure out where this is happening as I have not been able to setup debugging correctly from the adb shell.

Any help would be 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-06-09T00:31:58+00:00Added an answer on June 9, 2026 at 12:31 am

    Your code seems ok, maybe the error is in the encrypt method:

    enc.encrypt(inDecryptBuffer, *outEncryptBuffer, inputSize );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I lost my temper few days ago because of this simple problem. Can you
Totally lost with this one. Here's my code: theColor = [NSString stringWithFormat:@white]; NSLog(@%s, theColor);
I'm quite lost on this one and I hope someone here could help. My
I may be hopelessly lost here, but having come from a MVC.NET world I
I'm a bit lost with Subversion (1.5+) here: I modified the trunk in my
I lost a lot of time on this one, so I'm posting the question
I'm a little lost on how to achieve this problem. We have a list
Can ip packets be lost between two hosts on the same subnet, or does
Lost here. The following works in Chrome wonderfully, but in IE and FireFox undefined
I have lost idea how to generate some bivariate random mumbers, say in copula.

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.