【问题标题】:What is the padding type for Elliptic Curve Crypto椭圆曲线加密的填充类型是什么
【发布时间】:2014-02-14 17:17:39
【问题描述】:

在 ECC 的 SecKeyGeneratePair 之后,我尝试使用公钥加密明文。 SecKeyEncrypt 返回 -4(errSecUnimplemented)。我不确定填充类型是否正确。我尝试了我的 xcode 中的所有类型,它们都不能正常工作。有人可以解释为什么SecKeyEncrypt 返回 -4 吗?

(NSData *)encrypt:(NSString *)plainTextString key:(SecKeyRef)publicKey {

    NSData *data = [plainTextString dataUsingEncoding:NSUTF8StringEncoding];

    size_t encryptedDataLength = SecKeyGetBlockSize(publicKey);

    NSMutableData *encryptedData = [[NSMutableData alloc]
                                    initWithLength:encryptedDataLength];

    OSStatus err = SecKeyEncrypt(publicKey,
                                 kSecPaddingOAEP,
                                 [data bytes],
                                 [data length],
                                 [encryptedData mutableBytes],
                                 &encryptedDataLength);
    NSLog(@"errEXX:  %ld", err);

    [encryptedData setLength:encryptedDataLength];


    return encryptedData;
}

【问题讨论】:

    标签: ios objective-c encryption elliptic-curve


    【解决方案1】:

    Apple 的实现仅支持 ECDSA,可用于签名但不能用于加密。有关使用其他方案使用椭圆曲线进行加密的信息,请参阅Is it possible to use elliptic curve cryptography for encrypting data?

    【讨论】:

    • 这不再是真的。请参阅:kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-25
    相关资源
    最近更新 更多