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


Golang Source.Shuffle方法代码示例

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


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

示例1: maskEncoding

// maskEncoding produces encodings for the outputs of the InputMask and OutputMask. All randomness is derived from the
// random source; surface is common.Inside if these will be the masks between InputMask and InputXORTables or
// common.Outside if they'll be between TBoxOutputMask and OutputXORTables.
//
// See constructions/common/keygen_tools.go for information on the function returned.
func maskEncoding(rs *random.Source, surface common.Surface) func(int, int) encoding.Nibble {
	return func(position, subPosition int) encoding.Nibble {
		label := make([]byte, 16)
		label[0], label[1], label[2], label[3], label[4] = 'M', 'E', byte(position), byte(subPosition), byte(surface)

		return rs.Shuffle(label)
	}
}
开发者ID:OpenWhiteBox,项目名称:AES,代码行数:13,代码来源:keygen_primitives.go

示例2: xorEncoding

// xorEncoding produces encodings for intermediate values of XOR tables. All randomness is derived from the random
// source.
//
// If round < 10:
//   surface = common.Inside -- XOREncoding generates the encodings for the
//     HighXORTable (from TBoxTyiTable) in the given round.
//   surface = common.OUtside -- XOREncoding generates the encodings for the
//     LowXORTable (from MBInverseTable) in the given round.
//
// If round = 10:
//   surface = common.Inside -- XOREncoding generates the encodings for
//     InputXORTables (from InputMask).
//   surface = common.Outside -- XOREncoding generates the encodings for
//     OutputXORTables (from TBoxOutputMask).
//
// See constructions/common/keygen_tools.go for information on the function returned.
func xorEncoding(rs *random.Source, round int, surface common.Surface) func(int, int) encoding.Nibble {
	return func(position, gate int) encoding.Nibble {
		label := make([]byte, 16)
		label[0], label[1], label[2], label[3], label[4] = 'X', byte(round), byte(position), byte(gate), byte(surface)

		return rs.Shuffle(label)
	}
}
开发者ID:OpenWhiteBox,项目名称:AES,代码行数:24,代码来源:keygen_primitives.go

示例3: roundEncoding

// roundEncoding produces encodings for the output of a series of XOR tables / the input of a TBoxTyiTable or
// MBInverseTable. All randomness is derived from the random source; shift is the permutation that will be applied to
// the state matrix between the output of the XOR tables and the input of the next, or noshift if this is an input
// encoding.
//
// surface = common.Inside is used for "inter-round" encodings, like those between a HighXORTable and a MBInverseTable.
// surface = common.Outside is used for "intra-round" encodings, like between the InputXORTables and and the first
// TBoxTyiTable.
//
// See constructions/common/keygen_tools.go for information on the function returned.
func roundEncoding(rs *random.Source, round int, surface common.Surface, shift func(int) int) func(int) encoding.Nibble {
	return func(position int) encoding.Nibble {
		position = 2*shift(position/2) + position%2

		label := make([]byte, 16)
		label[0], label[1], label[2], label[3] = 'R', byte(round), byte(position), byte(surface)

		return rs.Shuffle(label)
	}
}
开发者ID:OpenWhiteBox,项目名称:AES,代码行数:20,代码来源:keygen_primitives.go

示例4: mbInverseEncoding

// mbInverseEncoding encodes the output of a MB^(-1) Table / the input of a LowXORTable.
//
// All randomness is derived from the random source; round is the current round; position is the byte-wise position in
// the state matrix being stretched; subPosition is the nibble-wise position in the Word table's output.
func mbInverseEncoding(rs *random.Source, round, position, subPosition int) encoding.Nibble {
	label := make([]byte, 16)
	label[0], label[1], label[2], label[3], label[4] = 'M', 'I', byte(round), byte(position), byte(subPosition)

	return rs.Shuffle(label)
}
开发者ID:OpenWhiteBox,项目名称:AES,代码行数:10,代码来源:keygen_primitives.go


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