Значение расшифровки RSA, равное нулю при конвертации ios Цель C - PullRequest
0 голосов
/ 23 апреля 2020
Code Used :

    NSData *data = [self decryptData:data withKeyRef:privateKey];
    NSString *decryptString2 = [[NSString alloc] initWithData:data 
    encoding:NSUTF8StringEncoding];//getting nil I am getting NIL when converting the decrypted data into string:


//Decryptiion method


- (NSString *)rsaDecryptWithData:(NSData*)data usingPublicKey:(BOOL)yes{
    NSData *wrappedSymmetricKey = data;
     NSLog(@"privateKey: %@ ", privateKey);
    SecKeyRef key = yes?self.publicKeyRef:privateKey;

    //key = [self getPrivateKeyRef]; // reejo remove

    size_t cipherBufferSize = SecKeyGetBlockSize(key);
    size_t keyBufferSize = [wrappedSymmetricKey length];

    NSMutableData *bits = [[NSMutableData alloc] init];
    OSStatus sanityCheck = SecKeyDecrypt(key,
                                         kSecPaddingNone,
                                         (const uint8_t *) [wrappedSymmetricKey bytes],
                                         cipherBufferSize,
                                         [bits mutableBytes],
                                         &keyBufferSize);

    if (sanityCheck != 0) {
        NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:sanityCheck userInfo:nil];
        NSLog(@"Error: %@", [error description]);
    }

    NSAssert(sanityCheck == noErr, @"Error decrypting, OSStatus == %ld.", (long)sanityCheck);

    [bits setLength:keyBufferSize];

    return [[NSString alloc] initWithData:bits
                                 encoding:NSUTF8StringEncoding];
}

NSData Я получаю: <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000000000000000000000000000000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 a6b7a17a b91b4033 7c094c1e 71b54f8a 8725f3e7 730192f8 1caca6b8 e253d214 74382e55 52ac0ade f6d2f056 ff7e357a 59152db2 2b862871 e57d826b e4b8c103 2d>

1003 *
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...