函数STAssertEqualObjects的隐式声明在C99中无效?为什么?

时间:2012-09-13 10:14:33

标签: ios

我想在iphone中加密邮件。我有模数和指数。 我从

引用的代码

How to Create SeckeyRef from exponent and modulus of Public key and use in SecKeyEncrypt method

+(NSString *)encryptRSA:(NSString *)plainTextString key:(NSString *)key
{

     NSString *publicKeyIdentifier = [NSString stringWithFormat:@"%@.publickey",[[NSBundle   mainBundle] bundleIdentifier]];
     [Crypto setPublicKey:key tag:(NSString *)publicKeyIdentifier];

     SecKeyRef publicKey = NULL;
     NSData * publicTag = [self PublicKeyItems/*publicKeyIdentifier      dataUsingEncoding:NSUTF8StringEncoding*/];
     NSMutableDictionary *queryPublicKey = [[[NSMutableDictionary alloc] init] autorelease];
     [queryPublicKey setObject:(id)kSecClassKey forKey:(id)kSecClass];
     [queryPublicKey setObject:publicTag forKey:(id)kSecAttrApplicationTag];
     [queryPublicKey setObject:(id)kSecAttrKeyTypeRSA forKey:(id)kSecAttrKeyType];
     [queryPublicKey setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecReturnRef];

     SecItemCopyMatching((CFDictionaryRef)queryPublicKey, (CFTypeRef *)&publicKey);

     if (!publicKey)
     {
         if(publicKey) CFRelease(publicKey);

         [Exception raise:FAILURE function:__PRETTY_FUNCTION__ line:__LINE__ description:@"Could not decrypt."];

}

我也同时使用BasicEncodingRules.m& 。H。但我有一个警告

+ (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 *testData1 = [testData berDecode];
    NSLog(@"testarray = %@",testData1);


    STAssertEqualObjects(testData, testData1, @"Big items decode failed");
// warning at this line, with content "Implicit declaration of function STAssertEqualObjects is invalid in C99"

    NSData *testData2 = [testData1 berData];
    NSLog(@"PublicKeyData using Publickeyitems = %@",testData2);
    return testData2;
}

所以我无法建立Crypto.o

请帮帮我! 不管怎样,谢谢

1 个答案:

答案 0 :(得分:0)

STAssertEqualObjects用于SenTest(即xcode附带的单元测试框架)。此代码是否在单元测试中?如果没有,那那就是你的问题。试试NSAssert*