tink-crypto / tink

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
https://developers.google.com/tink
Apache License 2.0
13.47k stars 1.18k forks source link

No manager for type 'type.googleapis.com/google.crypto.tink.HpkePrivateKey' has been registered #717

Closed CocoaJiang closed 7 months ago

CocoaJiang commented 11 months ago
NSString *path =  [[NSBundle mainBundle]pathForResource:@"hybrid_private_keyset" ofType:@"json"];
NSData *data = [NSData dataWithContentsOfFile:path];

NSError *error = nil;
TINKHybridConfig *hybridConfig = [[TINKHybridConfig alloc]initWithError:&error];
if(!hybridConfig || error){
    NSLog(@"%@",@"hybridConfig_error");
}
BOOL success = [TINKConfig registerConfig:hybridConfig error:&error];
if (!success) {
    NSLog(@"%@",@"registerConfig_error");
}
TINKJSONKeysetReader *reader = [[TINKJSONKeysetReader alloc]initWithSerializedKeyset:data error:&error];
if(error || !reader){
    NSLog(@"Json_ERROR");
}
TINKKeysetHandle *readHandle = [[TINKKeysetHandle alloc]initCleartextKeysetHandleWithKeysetReader:reader error:&error];
if(error || !readHandle){
    NSLog(@"handle_error");
}

id<TINKHybridDecrypt> hybridDecrypt = [TINKHybridDecryptFactory primitiveWithKeysetHandle:readHandle error:&error];
if(error || !hybridDecrypt){
    NSLog(@"%@",@"hybridDecrypt_error");
    return;
}

Tink 1.6.1 iOS 16 Xcode : 14.3.1

id hybridDecrypt = [TINKHybridDecryptFactory primitiveWithKeysetHandle:readHandle error:&error]; has error ,this error is Error Domain=TinkErrorDomain Code=5 "Tink Error" UserInfo={NSLocalizedDescription=Tink Error, NSLocalizedFailureReason=No manager for type 'type.googleapis.com/google.crypto.tink.HpkePrivateKey' has been registered.} jsonFile has type.googleapis.com/google.crypto.tink.HpkePrivateKey

tholenst commented 11 months ago

As per https://developers.google.com/tink/supported-key-types#hybrid_encryption HPKE is not supported in ObjC.

Can you add some more context?

morambro commented 7 months ago

Closing this issue. Please feel free to open a new issue in https://github.com/tink-crypto/tink-objc/issues if this is still an open problem and/or if you have additional questions/concerns.