【问题标题】:Iphone:how toValidate message authentication code(Mac)Iphone:如何验证消息验证码(Mac)
【发布时间】:2012-08-24 19:39:32
【问题描述】:

我有一个这样的 Java 代码:

public static byte[] generateMac(byte[] key, byte[] cipherText,int offset,int length,int mac_size_bits)
{
    byte[] result = null;
    KeyParameter keyParam = null;
    try {
        keyParam = new KeyParameter(key);
        CBCBlockCipherMac blockCipherMac = new CBCBlockCipherMac(new AESEngine(),mac_size_bits);
        result = new byte[blockCipherMac.getMacSize()];
        blockCipherMac.init(keyParam);
        blockCipherMac.update(cipherText, offset, length);
        blockCipherMac.doFinal(result, 0);
    } catch (Exception e) {
        // System.out.println(e);
        return null;
    } finally {
        keyParam = null;
    }
    return result;
}

在 iPhone 上我是这样写的:

- (NSData *)generateMac:(NSData *)key cipherText:(NSData *)cipherText offset:(int)offset length:(int)length mac_size_bits:(int)mac_size_bits

我的问题是,我应该对 iPhone 中的CBCBlockCipherMackeyparameters 使用哪种方法,谁能帮帮我?

【问题讨论】:

  • 哪个安全日志是,在 iPhone / Objective c 中,有 libKrypto,如果它的 AES,那么它的开源你可以使用......

标签: iphone objective-c authentication aes code-signing


【解决方案1】:

它的 MAC 加密 -- AFAIK 在 IOS 上没有一次性替换/等效

查看原始文档docs 和维基百科wiki

了解算法的工作原理,然后使用 CommonCrypto 进行复制

--抱歉没有更好的主意

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-22
    • 2018-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多