How to find out the modulus and exponent of RSA Public Key on iPhone/Objective C

前端 未结 4 776
感情败类
感情败类 2020-12-01 11:43

Is there a possible way to find out the modulus and exponent of the Public Key, created with SecKeyGeneratePair (the Security Framework in general)?

4条回答
  •  一个人的身影
    2020-12-01 12:03

    Something like the following is much more reliable:

    + (NSInteger)keyModulusSize:(NSData *)keyData
    {
        NSString *randomTag = [NSString ptk_randomStringOfLength:32];
        SecKeyRef key = [self addPublicKeyRef:keyData withTag:randomTag];
    
        NSInteger size = 0;
        if (key) {
            size = SecKeyGetBlockSize(key);
            [self removePublicKeyRef:randomTag];
        }
    
        return size;
    }
    

提交回复
热议问题