github.com/emmansun/gmsm@v0.29.1/zuc/core_asm.go (about)

     1  //go:build (amd64 || arm64 || ppc64 || ppc64le) && !purego
     2  
     3  package zuc
     4  
     5  // Generate single keyword, 4 bytes.
     6  //
     7  //go:noescape
     8  func genKeywordAsm(s *zucState32) uint32
     9  
    10  // Generate multiple keywords, n*4 bytes.
    11  //
    12  //go:noescape
    13  func genKeyStreamAsm(keyStream []uint32, pState *zucState32)
    14  
    15  func genKeyStream(keyStream []uint32, pState *zucState32) {
    16  	if supportsAES {
    17  		genKeyStreamAsm(keyStream, pState)
    18  		return
    19  	}
    20  	for i := 0; i < len(keyStream); i++ {
    21  		keyStream[i] = genKeyword(pState)
    22  	}
    23  }
    24  
    25  func genKeyword(s *zucState32) uint32 {
    26  	if supportsAES {
    27  		return genKeywordAsm(s)
    28  	}
    29  	s.bitReorganization()
    30  	z := s.x3 ^ s.f32()
    31  	s.enterWorkMode()
    32  	return z
    33  }