请人从指数和弹性模量是创建SecKeyRef
帮我Public exponent
= 和Public Modulus
= 008903fb6d15f352ed3b45add3216f632f7139954a5631337aba7d645ed38482e3a810b4db26aab4d1df58c147230f0c75631a3dd0554b50de44e79f4fcf205c89fd3f80e0ff8d16c2e9f56ed3ab177953d54c9c30357d04e677cedd9912906ef8a046d7b0185b7f2022a8e435b0c6ecaef93f089fc3aa3f3677550b5d842046c7,我想用这个SecKeyEncrypt作为公钥如何从公共密钥的指数和模量创建SeckeyRef和SecKeyEncrypt方法使用
3
A
回答
0
解决了问题NSData *publicTag=[self PublicKeyItems];
生成密钥对和调用方法
尝试导入BasicEncodingRules.h和.M在文件
- (NSData *)PublicKeyItems
{
NSString *exp = @"010001";
NSLog(@"Publickeyexp -%@",exp);
NSData *publickeyexpdata= [self stringasdata:exp];
NSLog(@"publickeyexpdata = %@",publickeyexpdata);
NSString *mod = @"008903fb6d15f352ed3b45add3216f632f7139954a5631337aba7d645ed38482e3a810b4db26aab4d1df58c147230f0c75631a3dd0554b50de44e79f4fcf205c89fd3f80e0ff8d16c2e9f56ed3ab177953d54c9c30357d04e677cedd9912906ef8a046d7b0185b7f2022a8e435b0c6ecaef93f089fc3aa3f3677550b5d842046c7";
NSLog(@"Publickeymod -%@",mod);
NSData *publickeymoddata= [self stringasdata:mod];
NSLog(@"publickeymod = %@",publickeyexpdata);
NSMutableArray *publicarray = [[NSMutableArray alloc] init];
[publicarray addObject:publickeyexpdata];
[publicarray addObject:publickeymoddata];
NSData *testData = [publicarray berData];
NSLog(@"testdata = %@",testData);
NSMutableArray *testArray2 = [testData berDecode];
NSLog(@"testarray = %@",testArray2);
//STAssertEqualObjects(testArray, testArray2,
// @"Big items decode failed");
NSData *testData2 = [testArray2 berData];
NSLog(@"PublicKeyData using Publickeyitems = %@",testData2);
return testData2;
}
-(NSData *)stringasdata:(NSString *)command {
command = [command stringByReplacingOccurrencesOfString:@" " withString:@""];
command = [command stringByReplacingOccurrencesOfString:@"<" withString:@""];
command = [command stringByReplacingOccurrencesOfString:@">" withString:@""];
NSLog(@"command= %@",command);
NSMutableData *commandToSend= [[NSMutableData alloc] init]; unsigned char whole_byte;
int len = [command length];
int n = len/2;
char byte_chars[3] = {'\0','\0','\0'}; int i;
for (i=0; i < n; i++) {
byte_chars[0] = [command characterAtIndex:i*2]; byte_chars[1] = [command characterAtIndex:i*2+1]; whole_byte = strtol(byte_chars, NULL, 16); [commandToSend appendBytes:&whole_byte length:1];
}
// [commandToSend setLength:[commandToSend length]-1];
return commandToSend;
}
相关问题
- 1. C++从CNG模数和指数导入RSA公共密钥
- 2. iOS - 从指数+模数创建SecKeyRef
- 3. 从模数和指数中创建一个rsa公钥
- 4. 如何从SSH-RSA提取指数和模量密钥文件
- 5. 生成从模公钥和指数
- 6. 如何使用Moose创建私有/公共变量和函数?
- 7. 从私钥和公钥创建密钥库
- 8. 如何与公共密钥
- 9. 如何从公钥中找到模数和指数?
- 10. 使用OpenSSL从文件设置私人和公共EC密钥
- 11. RSA使用Python中的公共模和指数对密码进行加密
- 12. 如何创建一个谷歌项目的公共API密钥
- 13. 如何使用openssl和php创建小型公钥/私钥?
- 14. 如何使用RSA私钥和公钥创建.der文件?
- 15. 如何使用openSSL和公钥加密和解密xml
- 16. c#的RSA公共密钥的公钥#
- 17. 如何创建公共方法?
- 18. 在JAVA中使用公共和私有RSA密钥进行加密和解密
- 19. 创建公钥和私钥的Gem?
- 20. 如何在C#中使用模数D指数创建专用RSA密钥?
- 21. RSA使用给定的公钥XML加密字符串 - 模块和指数 - ANDROID
- 22. 创建ECDSA公钥给定曲线和公共点?
- 23. 基于模数和公开指数重新生成公钥和私钥
- 24. 加载公钥为公共加密创建rsa对象
- 25. 如何从密钥库中读取私钥和公钥密钥库
- 26. 使用模数和公开指数的C#RSA加密
- 27. 如何从RSA模数创建PEM格式的RSA公钥?
- 28. 无法获取StrongNameKeyPair的公共密钥
- 29. 如何使用rsa c仅公钥进行加密和解密#
- 30. 使用Javascript/PHP验证公共密钥
主任Purnima, 你能粘贴完整代码。我看到代码转换指数&模数为NSData,但我没有转换为SecRefKey(这是首选公钥)。提前致谢。 -Kiran – 2012-10-01 11:07:17