iOS에서 ECC를 사용하는 예가 있습니까?iOS에서 ECC를 사용하는 방법
Apple 개발자 문서의 kSecAttrKeyTypeEC에 주목했지만 일반 키 쌍에 사용할 수 없습니다. 코드 아래
는 CryptoExercise가
// Container dictionaries.
NSMutableDictionary * privateKeyAttr = [[NSMutableDictionary alloc] init];
NSMutableDictionary * publicKeyAttr = [[NSMutableDictionary alloc] init];
NSMutableDictionary * keyPairAttr = [[NSMutableDictionary alloc] init];
// Set top level dictionary for the keypair.
[keyPairAttr setObject:(id)kSecAttrKeyTypeEC forKey:(id)kSecAttrKeyType];
[keyPairAttr setObject:[NSNumber numberWithUnsignedInteger:keySize] forKey:(id)kSecAttrKeySizeInBits];
// Set the private key dictionary.
[privateKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecAttrIsPermanent];
[privateKeyAttr setObject:privateTag forKey:(id)kSecAttrApplicationTag];
// See SecKey.h to set other flag values.
// Set the public key dictionary.
[publicKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecAttrIsPermanent];
[publicKeyAttr setObject:publicTag forKey:(id)kSecAttrApplicationTag];
// See SecKey.h to set other flag values.
// Set attributes to top level dictionary.
[keyPairAttr setObject:privateKeyAttr forKey:(id)kSecPrivateKeyAttrs];
[keyPairAttr setObject:publicKeyAttr forKey:(id)kSecPublicKeyAttrs];
// SecKeyGeneratePair returns the SecKeyRefs just for educational purposes.
sanityCheck = SecKeyGeneratePair((CFDictionaryRef)keyPairAttr, &publicKeyRef, &privateKeyRef);
LOGGING_FACILITY(sanityCheck == noErr && publicKeyRef != NULL && privateKeyRef != NULL, @"Something really bad went wrong with generating the key pair.");
sanityCheck 항상 'errSecParam'을 의미 -50를 반환의 예에서 수정됩니다.
정말 사용 방법을 모르겠습니다. 읽어 주셔서 감사합니다.
keysize = 256이지만 또 다른 문제는 내가 SecKeyRawSign을 사용할 때 -1을 반환하고 -1 반환 값에 대한 설명을 찾을 수없는 경우 코드가 전달 된 것입니다. 문제? – Cylon
이 문제에 대한 해결책을 찾았습니까? – Gunhan