当前位置: 首页>>代码示例>>Golang>>正文


Golang Construction.UnShiftRows方法代码示例

本文整理汇总了Golang中github.com/OpenWhiteBox/AES/constructions/saes.Construction.UnShiftRows方法的典型用法代码示例。如果您正苦于以下问题:Golang Construction.UnShiftRows方法的具体用法?Golang Construction.UnShiftRows怎么用?Golang Construction.UnShiftRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/OpenWhiteBox/AES/constructions/saes.Construction的用法示例。


在下文中一共展示了Construction.UnShiftRows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GenerateDecryptionKeys

// GenerateDecryptionKeys creates a white-boxed version of AES with given key for decryption, with any non-determinism
// generated by seed. Opts specifies what type of input and output masks we put on the construction and should be in
// common.{IndependentMasks, SameMasks, MatchingMasks}.
func GenerateDecryptionKeys(key, seed []byte, opts common.KeyGenerationOpts) (out Construction, inputMask, outputMask matrix.Matrix) {
	rs := random.NewSource("Chow Decryption", seed)

	constr := saes.Construction{key}
	roundKeys := constr.StretchedKey()

	// Last key needs to be unshifted for decryption to work right.
	constr.UnShiftRows(roundKeys[10])

	skinny := func(pos int) table.Byte {
		return common.InvTBox{constr, 0x00, roundKeys[0][pos]}
	}

	wide := func(round, pos int) table.Word {
		if round == 0 {
			return table.ComposedToWord{
				common.InvTBox{Constr: constr, KeyByte1: roundKeys[10][pos], KeyByte2: roundKeys[9][pos]},
				common.InvTyiTable(pos % 4),
			}
		} else {
			return table.ComposedToWord{
				common.InvTBox{Constr: constr, KeyByte2: roundKeys[9-round][pos]},
				common.InvTyiTable(pos % 4),
			}
		}
	}

	generateKeys(&rs, opts, &out, &inputMask, &outputMask, common.UnShiftRows, skinny, wide)

	return
}
开发者ID:OpenWhiteBox,项目名称:AES,代码行数:34,代码来源:keygen.go

示例2: GenerateDecryptionKeys

// GenerateDecryptionKeys creates a white-boxed version of the AES key `key` for decryption, with any non-determinism
// generated by `seed`.  The `opts` argument works the same as above.
func GenerateDecryptionKeys(key, seed []byte, opts KeyGenerationOpts) (out Construction, inputMask, outputMask matrix.Matrix) {
	constr := saes.Construction{key}
	roundKeys := constr.StretchedKey()

	// Last key needs to be unshifted for decryption to work right.
	constr.UnShiftRows(roundKeys[10])

	skinny := func(pos int) table.Byte {
		return InvTBox{constr, 0x00, roundKeys[0][pos]}
	}

	wide := func(round, pos int) table.Word {
		if round == 0 {
			return table.ComposedToWord{
				InvTBox{constr, roundKeys[10][pos], roundKeys[9][pos]},
				InvTyiTable(pos % 4),
			}
		} else {
			return table.ComposedToWord{
				InvTBox{constr, 0x00, roundKeys[9-round][pos]},
				InvTyiTable(pos % 4),
			}
		}
	}

	generateKeys(seed, opts, &out, &inputMask, &outputMask, unshiftRows, skinny, wide)

	return
}
开发者ID:gaurav1981,项目名称:AES,代码行数:31,代码来源:keygen.go

示例3: Decode

func (sr shiftrows) Decode(in [16]byte) (out [16]byte) {
	constr := saes.Construction{}

	copy(out[:], in[:])
	constr.UnShiftRows(out[:])

	return
}
开发者ID:OpenWhiteBox,项目名称:AES,代码行数:8,代码来源:encoding.go


注:本文中的github.com/OpenWhiteBox/AES/constructions/saes.Construction.UnShiftRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。