func testConstruction() (*chow.Construction, []byte) { key := test_vectors.AESVectors[50].Key seed := test_vectors.AESVectors[51].Key constr, _, _ := chow.GenerateEncryptionKeys(key, seed, chow.SameMasks(chow.IdentityMask)) return &constr, key }
func ExtractKey(cand ast.Expr) ([]byte, bool) { // Verify expression contains a byte slice. compositeLit, ok := cand.(*ast.CompositeLit) if !ok { return nil, false } arrayType, ok := compositeLit.Type.(*ast.ArrayType) if !ok { return nil, false } elt, ok := arrayType.Elt.(*ast.Ident) if !ok || elt.Name != "byte" || elt.Obj != nil { return nil, false } // Extract raw key. key := []byte{} for _, e := range compositeLit.Elts { basicLit, ok := e.(*ast.BasicLit) if !ok || basicLit.Kind != token.INT { return nil, false } num, err := strconv.ParseUint(basicLit.Value, 0, 8) if err != nil { return nil, false } key = append(key, byte(num)) } if len(key) != 16 { return nil, false } // Mask key. seed := make([]byte, 16) rand.Read(seed) constr, _, _ := chow.GenerateEncryptionKeys(key, seed, chow.SameMasks(chow.IdentityMask)) return constr.Serialize(), true }