Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix key length function has a bug #17

Open
ucheema opened this issue Aug 30, 2012 · 1 comment
Open

Fix key length function has a bug #17

ucheema opened this issue Aug 30, 2012 · 1 comment

Comments

@ucheema
Copy link

ucheema commented Aug 30, 2012

if you try decrypting with a 16 byte key it converts the keylength to 24 bytes

the following function should be changed to add <= for 16 and 24 byte comparisons

static void FixKeyLengths( CCAlgorithm algorithm, NSMutableData * keyData, NSMutableData * ivData )
{
NSUInteger keyLength = [keyData length];
switch ( algorithm )
{
case kCCAlgorithmAES128:
{
if ( keyLength <= 16 )
{
[keyData setLength: 16];
}
else if ( keyLength <= 24 )
{
[keyData setLength: 24];
}
else
{
[keyData setLength: 32];
}

        break;
@rckoenes
Copy link

Guess this also goes for the kCCAlgorithmCAST

case kCCAlgorithmCAST:
{
    if ( keyLength <= 5 )
    {
        [keyData setLength: 5];
    }
    else if ( keyLength > 16 )
    {
        [keyData setLength: 16];
    }

    break;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants