zoukankan      html  css  js  c++  java
  • sha-hmac

    MAC----message authentication code,保证数据完整性的一个技术。

    HMAC类似于标准的sha运算,只是对于生成的mac增加了基于key的密钥保护

      生成的mac值,随着sender的payload一起发送给receiveder。

      receiveder,拿到mac先进行数据完整性的校验-----重新计算payload,得到自己的mac,与传输过来的mac进行比较。

    HMAC对应的nist标准为FIPS 198-1,其中只是规定了hmac的算法流程,mac计算engine,可以使用nist中推荐的任何hash 算法

    HMAC需要的输入信息;

      1) hash engine的block size的大小(以byte为单位),B

      2) inner pad;byte---"0x36",重复B次;

       outer pad;byte---"0x5c",重复B次;

      3) 输入的key,长度任意,需要经过定义的padding,转变为K0;

     

    流程:

      1) padding key,目的是将输入的任意长度的key,转换为block_size的大小。

        如果输入的key的长度小于等于block size的大小,直接append “0”;

        如果输入的key的长度大于block size的大小,先进行hash engine计算,之后append “0”,组成block size大小

      2) 计算两次hash,输出最终的mac值,

        hash((K0+opad) || hash((K0+ipad) || text ))

      

  • 相关阅读:
    POJ 1981 Circle and Points (扫描线)
    UVA 1514 Piece it together (二分图匹配)
    CodeForces 140D New Year Contest
    HDU 4863 Centroid of a Tree
    HDU 4865 Peter's Hobby
    HDU 4870 Rating
    HDU 4864 Task
    CodeForces 766E Mahmoud and a xor trip
    CodeForces 766D Mahmoud and a Dictionary
    CodeForces 767D Cartons of milk
  • 原文地址:https://www.cnblogs.com/-9-8/p/9645034.html
Copyright © 2011-2022 走看看