Overwriting the returned pointer to the output parameter

I play in the openSSL library and I need to comb pointers and I am having difficulty.

I have an objective-c method:

-(unsigned char *)encryptTake1:(unsigned char *)input inputLength:(int)inLen outputLength:(int*)outLen;

It takes some data, encrypts it, and returns a pointer to the data and the length of the data as an output parameter.

I want to change this so that the encrypted data is also treated as an output parameter, and the return value is used to indicate success or failure. This is what I have:

-(int)encryptTake2:(unsigned char *)input inputLength:(int)inLen output:(unsigned char *)output outputLength:(int*)outLen;

This does not work. What am I doing wrong? I think the problem is what (unsigned char *)is wrong. If it’s (unsigned char *)wrong, I assume that I will also need to change the linking method outputin this method. How?

0
1

, .

-encryptTake1:? , , unsigned char** encryptTake2:

-(int)encryptTake2:(unsigned char *)input inputLength:(int)inLen output:(unsigned char **)outputPtr outputLength:(int*)outLen
{
    *outputPtr = malloc(1024);
    unsigned char* output = *outputPtr;
    strcpy(output, "hello");
    ...
}
+2

Source: https://habr.com/ru/post/1762752/


All Articles