2

我试图通过使用软件来提醒和报告失败的MAC验证尝试,并与中层管理人员共享结果,从而使人们意识到加密身份验证的必要性。

我不是密码学家,但我看到了正确实施的价值。理想情况下,我想创建一个报告,说明 X 攻击已被阻止。

这是一个有效的想法,还是过于简单化?如果没有,我应该从哪里开始实施它?(低级 AES、PGP 等?)

4

2 回答 2

1

这是一个C# MAC 代码示例,可以修改为在身份验证失败时发出警报或记录。这是一个不完整的示例,不应按原样使用,因为在实施之前需要考虑许多其他细节 Authenticate-then-Encrypt (AtE)Encrypt-then-Authenticate (EtA)

很高兴知道exception与此错误相关的性能计数器、日志文件或 DLL。我将调查 BouncyCastle 以查看相应的异常在哪里。

// Compares the key in the source file with a new key created for the data portion of the file. If the keys 
// compare the data has not been tampered with.
public static bool VerifyFile(byte[] key, String sourceFile)
{
    bool err = false;
    // Initialize the keyed hash object. 
    using (HMACSHA1 hmac = new HMACSHA1(key))
    {
        // Create an array to hold the keyed hash value read from the file.
        byte[] storedHash = new byte[hmac.HashSize / 8];
        // Create a FileStream for the source file.
        using (FileStream inStream = new FileStream(sourceFile, FileMode.Open))
        {
            // Read in the storedHash.
            inStream.Read(storedHash, 0, storedHash.Length);
            // Compute the hash of the remaining contents of the file.
            // The stream is properly positioned at the beginning of the content, 
            // immediately after the stored hash value.
            byte[] computedHash = hmac.ComputeHash(inStream);
            // compare the computed hash with the stored value

            for (int i = 0; i < storedHash.Length; i++)
            {
                if (computedHash[i] != storedHash[i])
                {
                    err = true;
                }
            }
        }
    }
    if (err)
    {
        Console.WriteLine("Hash values differ! Signed file has been tampered with!");
        // 
        // 
        // <-------- This is where the MAC alerting would go
        // 
        // 

        return false;
    }
    else
    {
        Console.WriteLine("Hash values agree -- no tampering occurred.");
        return true;
    }

} //end VerifyFile
于 2011-10-11T13:54:28.543 回答
0

任何验证者无法仅根据他所拥有的信息来确定密码是否有效的方法。唯一不会让您警告和报告失败的身份验证尝试的方案是身份验证尝试可以绕过服务器的方案。

例如,如果身份验证器是 AES 密钥(可以从密码或密码短语生成),只需质询身份验证代理以加密或解密随机 128 位字符串。攻击者得到的只是一个随机的 128 位字符串。因此,要尝试查看特定密码是否有效,他必须向您发送回复,您可以记录不正确的密码。

于 2011-10-10T16:09:16.013 回答