From a4aba782e08e8bbaf6f6deb9c3c3385c789c0ccd Mon Sep 17 00:00:00 2001 From: WinfredLIN Date: Thu, 17 Oct 2024 16:13:14 +0800 Subject: [PATCH 1/6] chore: update form dms --- go.mod | 3 +- go.sum | 8 +- .../pkg/dms-common/api/dms/v1/db_service.go | 3 + .../dms/pkg/dms-common/api/dms/v1/project.go | 44 + .../pkg/dms-common/dmsobject/db_service.go | 51 +- .../dms/pkg/dms-common/dmsobject/project.go | 29 +- vendor/github.com/gocarina/gocsv/.gitignore | 1 - vendor/github.com/gocarina/gocsv/.travis.yml | 4 - vendor/github.com/gocarina/gocsv/LICENSE | 21 - vendor/github.com/gocarina/gocsv/README.md | 173 -- vendor/github.com/gocarina/gocsv/csv.go | 554 ----- vendor/github.com/gocarina/gocsv/decode.go | 539 ----- vendor/github.com/gocarina/gocsv/encode.go | 169 -- vendor/github.com/gocarina/gocsv/reflect.go | 266 -- vendor/github.com/gocarina/gocsv/safe_csv.go | 38 - vendor/github.com/gocarina/gocsv/types.go | 489 ---- .../github.com/gocarina/gocsv/unmarshaller.go | 134 -- vendor/github.com/pjbgf/sha1cd/cgo/sha1.c | 2144 ----------------- vendor/github.com/pjbgf/sha1cd/cgo/sha1.h | 114 - .../github.com/pjbgf/sha1cd/cgo/ubc_check.c | 297 --- .../github.com/pjbgf/sha1cd/cgo/ubc_check.h | 64 - .../x/crypto/ssh/test/sshd_test_pw.c | 173 -- .../x/tools/go/loader/testdata/issue46877/x.h | 5 - vendor/modules.txt | 5 +- 24 files changed, 124 insertions(+), 5204 deletions(-) delete mode 100644 vendor/github.com/gocarina/gocsv/.gitignore delete mode 100644 vendor/github.com/gocarina/gocsv/.travis.yml delete mode 100644 vendor/github.com/gocarina/gocsv/LICENSE delete mode 100644 vendor/github.com/gocarina/gocsv/README.md delete mode 100644 vendor/github.com/gocarina/gocsv/csv.go delete mode 100644 vendor/github.com/gocarina/gocsv/decode.go delete mode 100644 vendor/github.com/gocarina/gocsv/encode.go delete mode 100644 vendor/github.com/gocarina/gocsv/reflect.go delete mode 100644 vendor/github.com/gocarina/gocsv/safe_csv.go delete mode 100644 vendor/github.com/gocarina/gocsv/types.go delete mode 100644 vendor/github.com/gocarina/gocsv/unmarshaller.go delete mode 100644 vendor/github.com/pjbgf/sha1cd/cgo/sha1.c delete mode 100644 vendor/github.com/pjbgf/sha1cd/cgo/sha1.h delete mode 100644 vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.c delete mode 100644 vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.h delete mode 100644 vendor/golang.org/x/crypto/ssh/test/sshd_test_pw.c delete mode 100644 vendor/golang.org/x/tools/go/loader/testdata/issue46877/x.h diff --git a/go.mod b/go.mod index 8c96b9062c..40743f28ea 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/Masterminds/semver/v3 v3.1.1 - github.com/actiontech/dms v0.0.0-20241010085644-dd7513f0051e + github.com/actiontech/dms v0.0.0-20241017075851-7c8f25660c39 github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62 github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240806065717-29cde7000ef5 github.com/agiledragon/gomonkey v2.0.2+incompatible @@ -66,7 +66,6 @@ require ( require ( github.com/aliyun/credentials-go v1.1.2 - github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 github.com/hashicorp/go-version v1.7.0 github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.69 github.com/nicksnyder/go-i18n/v2 v2.4.0 diff --git a/go.sum b/go.sum index 734786ac03..da27c5b767 100644 --- a/go.sum +++ b/go.sum @@ -46,10 +46,8 @@ github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdc github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/actiontech/dms v0.0.0-20241010022353-9b4591e71b26 h1:DVUD1u/1vC6yHqj171JCYgyVhFNWlQGp2y/wzKEGhJo= -github.com/actiontech/dms v0.0.0-20241010022353-9b4591e71b26/go.mod h1:Jm+tDoBYmX8R8zqgPJRq1NwZXdxO/F+HxVRJVF65WXA= -github.com/actiontech/dms v0.0.0-20241010085644-dd7513f0051e h1:eEnYDdYR3f8lvlUtCI0bfd/vp0QUiJTf8TzGkwvshUw= -github.com/actiontech/dms v0.0.0-20241010085644-dd7513f0051e/go.mod h1:Jm+tDoBYmX8R8zqgPJRq1NwZXdxO/F+HxVRJVF65WXA= +github.com/actiontech/dms v0.0.0-20241017075851-7c8f25660c39 h1:9EEP+D1p1i58sAlXQnTUPV/czYAwK5/kHKPVugBXm20= +github.com/actiontech/dms v0.0.0-20241017075851-7c8f25660c39/go.mod h1:Jm+tDoBYmX8R8zqgPJRq1NwZXdxO/F+HxVRJVF65WXA= github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62 h1:JM7WnLzlvXOGE90KKd+aigi+qUDS+U5dLwQMNpTKZxE= github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62/go.mod h1:adDZHhAf2LRMx2h0JzofPXn12x2XlyQjVE116KXquwo= github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240806065717-29cde7000ef5 h1:vyQVrkYPzUV9d7gSvOWoezwWMTiC4jc3f3Hpianefq0= @@ -305,8 +303,6 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 h1:FWNFq4fM1wPfcK40yHE5UO3RUdSNPaBC+j3PokzA6OQ= -github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= github.com/goccy/go-graphviz v0.0.5/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= diff --git a/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/db_service.go b/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/db_service.go index 4fca05ef0b..011af59499 100644 --- a/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/db_service.go +++ b/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/db_service.go @@ -70,6 +70,9 @@ type ListDBServiceReq struct { // project id // in:path ProjectUid string `param:"project_uid" json:"project_uid"` + // filter db services by db service id list using in condition + // in:query + FilterByDBServiceIds []string `query:"filter_by_db_service_ids" json:"filter_by_db_service_ids"` // the db service fuzzy keyword,include host/port // in:query FuzzyKeyword string `query:"fuzzy_keyword" json:"fuzzy_keyword"` diff --git a/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/project.go b/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/project.go index 06c1a8fc36..4852b0f41a 100644 --- a/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/project.go +++ b/vendor/github.com/actiontech/dms/pkg/dms-common/api/dms/v1/project.go @@ -22,6 +22,12 @@ type ListProjectReq struct { FilterByName string `query:"filter_by_name" json:"filter_by_name"` // filter the Project UID FilterByUID string `query:"filter_by_uid" json:"filter_by_uid"` + // filter project by project id list, using in condition + // in:query + FilterByProjectUids []string `query:"filter_by_project_uids" json:"filter_by_project_uids"` + // filter project by project priority + // in:query + FilterByProjectPriority ProjectPriority `query:"filter_by_project_priority" json:"filter_by_project_priority"` } // swagger:enum ProjectOrderByField @@ -31,6 +37,42 @@ const ( ProjectOrderByName ProjectOrderByField = "name" ) +// swagger:enum ProjectPriority +type ProjectPriority string + +const ( + ProjectPriorityHigh ProjectPriority = "high" + ProjectPriorityMedium ProjectPriority = "medium" + ProjectPriorityLow ProjectPriority = "low" + ProjectPriorityUnknown ProjectPriority = "unknown" // 当数据库中数据存在问题时,返回该状态 +) + +func ToPriorityNum(priority ProjectPriority) uint8 { + switch priority { + case ProjectPriorityHigh: + return 30 + case ProjectPriorityMedium: + return 20 + case ProjectPriorityLow: + return 10 + default: + return 20 // 默认优先级为中 + } +} + +func ToPriority(priority uint8) ProjectPriority { + switch priority { + case 10: + return ProjectPriorityLow + case 20: + return ProjectPriorityMedium + case 30: + return ProjectPriorityHigh + default: + return ProjectPriorityUnknown + } +} + // A dms Project type ListProject struct { // Project uid @@ -49,6 +91,8 @@ type ListProject struct { CreateUser UidWithName `json:"create_user"` // create time CreateTime strfmt.DateTime `json:"create_time"` + // project priority + ProjectPriority ProjectPriority `json:"project_priority" enums:"high,medium,low"` } type Business struct { diff --git a/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/db_service.go b/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/db_service.go index 700c836d1a..9f7c9e76ca 100644 --- a/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/db_service.go +++ b/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/db_service.go @@ -14,12 +14,55 @@ func ListDbServices(ctx context.Context, dmsAddr string, req dmsV1.ListDBService "Authorization": pkgHttp.DefaultDMSToken, } - placeholder := "%s%s?page_size=%d&page_index=%d&order_by=%v&filter_by_business=%s&filter_by_host=%s&filter_by_uid=%s&filter_by_port=%s&filter_by_db_type=%s&filter_by_name=%s" - requestUri := fmt.Sprintf(placeholder, dmsAddr, dmsV1.GetDBServiceRouter(req.ProjectUid), req.PageSize, req.PageIndex, req.OrderBy, url.QueryEscape(req.FilterByBusiness), req.FilterByHost, req.FilterByUID, req.FilterByPort, url.QueryEscape(req.FilterByDBType), url.QueryEscape(req.FilterByName)) + // 构建基础 URL + baseURL, err := url.Parse(fmt.Sprintf("%s%s", dmsAddr, dmsV1.GetDBServiceRouter(req.ProjectUid))) + if err != nil { + return nil, 0, fmt.Errorf("failed to parse base URL: %v", err) + } - reply := &dmsV1.ListDBServiceReply{} + // 构建查询参数 + query := url.Values{} + query.Set("page_size", fmt.Sprintf("%d", req.PageSize)) + query.Set("page_index", fmt.Sprintf("%d", req.PageIndex)) + + if req.OrderBy != "" { + query.Set("order_by", fmt.Sprintf("%v", req.OrderBy)) + } + if req.FilterByBusiness != "" { + query.Set("filter_by_business", url.QueryEscape(req.FilterByBusiness)) + } + if req.FilterByHost != "" { + query.Set("filter_by_host", req.FilterByHost) + } + if req.FilterByUID != "" { + query.Set("filter_by_uid", req.FilterByUID) + } + if req.FilterByName != "" { + query.Set("filter_by_name", req.FilterByName) + } + if req.FilterByPort != "" { + query.Set("filter_by_port", req.FilterByPort) + } + if req.FilterByDBType != "" { + query.Set("filter_by_db_type", req.FilterByDBType) + } + if req.FuzzyKeyword != "" { + query.Set("fuzzy_keyword", req.FuzzyKeyword) + } + if req.IsEnableMasking != nil { + query.Set("is_enable_masking", fmt.Sprintf("%t", *req.IsEnableMasking)) + } - if err := pkgHttp.Get(ctx, requestUri, header, nil, reply); err != nil { + for _, id := range req.FilterByDBServiceIds { + query.Add("filter_by_db_service_ids", id) + } + + // 将查询参数附加到 URL + baseURL.RawQuery = query.Encode() + + // 调用 HTTP GET 请求 + reply := &dmsV1.ListDBServiceReply{} + if err := pkgHttp.Get(ctx, baseURL.String(), header, nil, reply); err != nil { return nil, 0, err } if reply.Code != 0 { diff --git a/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/project.go b/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/project.go index 2e7d4e8b11..27d74aa34a 100644 --- a/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/project.go +++ b/vendor/github.com/actiontech/dms/pkg/dms-common/dmsobject/project.go @@ -3,6 +3,7 @@ package dmsobject import ( "context" "fmt" + "net/url" dmsV1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1" pkgHttp "github.com/actiontech/dms/pkg/dms-common/pkg/http" @@ -15,10 +16,32 @@ func ListProjects(ctx context.Context, dmsAddr string, req dmsV1.ListProjectReq) reply := &dmsV1.ListProjectReply{} - url := fmt.Sprintf("%v%v?page_size=%v&page_index=%v&filter_by_name=%v&filter_by_uid=%v", dmsAddr, dmsV1.GetProjectsRouter(), req.PageSize, req.PageIndex, req.FilterByName, req.FilterByUID) + baseURL, err := url.Parse(fmt.Sprintf("%v%v", dmsAddr, dmsV1.GetProjectsRouter())) + if err != nil { + return nil, 0, fmt.Errorf("failed to parse base URL: %v", err) + } + // 构建查询参数 + query := url.Values{} + query.Set("page_size", fmt.Sprintf("%v", req.PageSize)) + query.Set("page_index", fmt.Sprintf("%v", req.PageIndex)) + + if req.FilterByName != "" { + query.Set("filter_by_name", req.FilterByName) + } + if req.FilterByUID != "" { + query.Set("filter_by_uid", req.FilterByUID) + } + if req.FilterByProjectPriority != "" { + query.Set("filter_by_project_priority", string(req.FilterByProjectPriority)) + } + for _, projectUid := range req.FilterByProjectUids { + query.Add("filter_by_project_uids", projectUid) + } + + baseURL.RawQuery = query.Encode() - if err := pkgHttp.Get(ctx, url, header, nil, reply); err != nil { - return nil, 0, fmt.Errorf("failed to list project from %v: %v", url, err) + if err := pkgHttp.Get(ctx, baseURL.String(), header, nil, reply); err != nil { + return nil, 0, fmt.Errorf("failed to list project from %v: %v", baseURL.String(), err) } if reply.Code != 0 { return nil, 0, fmt.Errorf("http reply code(%v) error: %v", reply.Code, reply.Message) diff --git a/vendor/github.com/gocarina/gocsv/.gitignore b/vendor/github.com/gocarina/gocsv/.gitignore deleted file mode 100644 index 485dee64bc..0000000000 --- a/vendor/github.com/gocarina/gocsv/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea diff --git a/vendor/github.com/gocarina/gocsv/.travis.yml b/vendor/github.com/gocarina/gocsv/.travis.yml deleted file mode 100644 index 61c24c6c97..0000000000 --- a/vendor/github.com/gocarina/gocsv/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: go -arch: - - amd64 - - ppc64le diff --git a/vendor/github.com/gocarina/gocsv/LICENSE b/vendor/github.com/gocarina/gocsv/LICENSE deleted file mode 100644 index 052a371193..0000000000 --- a/vendor/github.com/gocarina/gocsv/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Picques - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/gocarina/gocsv/README.md b/vendor/github.com/gocarina/gocsv/README.md deleted file mode 100644 index 085f747dae..0000000000 --- a/vendor/github.com/gocarina/gocsv/README.md +++ /dev/null @@ -1,173 +0,0 @@ -Go CSV -===== - -The GoCSV package aims to provide easy serialization and deserialization functions to use CSV in Golang - -API and techniques inspired from https://godoc.org/gopkg.in/mgo.v2 - -[![GoDoc](https://godoc.org/github.com/gocarina/gocsv?status.png)](https://godoc.org/github.com/gocarina/gocsv) -[![Build Status](https://travis-ci.org/gocarina/gocsv.svg?branch=master)](https://travis-ci.org/gocarina/gocsv) - -Installation -===== - -```go get -u github.com/gocarina/gocsv``` - -Full example -===== - -Consider the following CSV file - -```csv - -client_id,client_name,client_age -1,Jose,42 -2,Daniel,26 -3,Vincent,32 - -``` - -Easy binding in Go! ---- - -```go - -package main - -import ( - "fmt" - "os" - - "github.com/gocarina/gocsv" -) - -type NotUsed struct { - Name string -} - -type Client struct { // Our example struct, you can use "-" to ignore a field - Id string `csv:"client_id"` - Name string `csv:"client_name"` - Age string `csv:"client_age"` - NotUsedString string `csv:"-"` - NotUsedStruct NotUsed `csv:"-"` -} - -func main() { - clientsFile, err := os.OpenFile("clients.csv", os.O_RDWR|os.O_CREATE, os.ModePerm) - if err != nil { - panic(err) - } - defer clientsFile.Close() - - clients := []*Client{} - - if err := gocsv.UnmarshalFile(clientsFile, &clients); err != nil { // Load clients from file - panic(err) - } - for _, client := range clients { - fmt.Println("Hello", client.Name) - } - - if _, err := clientsFile.Seek(0, 0); err != nil { // Go to the start of the file - panic(err) - } - - clients = append(clients, &Client{Id: "12", Name: "John", Age: "21"}) // Add clients - clients = append(clients, &Client{Id: "13", Name: "Fred"}) - clients = append(clients, &Client{Id: "14", Name: "James", Age: "32"}) - clients = append(clients, &Client{Id: "15", Name: "Danny"}) - csvContent, err := gocsv.MarshalString(&clients) // Get all clients as CSV string - //err = gocsv.MarshalFile(&clients, clientsFile) // Use this to save the CSV back to the file - if err != nil { - panic(err) - } - fmt.Println(csvContent) // Display all clients as CSV string - -} - -``` - -Customizable Converters ---- - -```go - -type DateTime struct { - time.Time -} - -// Convert the internal date as CSV string -func (date *DateTime) MarshalCSV() (string, error) { - return date.Time.Format("20060201"), nil -} - -// You could also use the standard Stringer interface -func (date *DateTime) String() (string) { - return date.String() // Redundant, just for example -} - -// Convert the CSV string as internal date -func (date *DateTime) UnmarshalCSV(csv string) (err error) { - date.Time, err = time.Parse("20060201", csv) - return err -} - -type Client struct { // Our example struct with a custom type (DateTime) - Id string `csv:"id"` - Name string `csv:"name"` - Employed DateTime `csv:"employed"` -} - -``` - -Customizable CSV Reader / Writer ---- - -```go - -func main() { - ... - - gocsv.SetCSVReader(func(in io.Reader) gocsv.CSVReader { - r := csv.NewReader(in) - r.Comma = '|' - return r // Allows use pipe as delimiter - }) - - ... - - gocsv.SetCSVReader(func(in io.Reader) gocsv.CSVReader { - r := csv.NewReader(in) - r.LazyQuotes = true - r.Comma = '.' - return r // Allows use dot as delimiter and use quotes in CSV - }) - - ... - - gocsv.SetCSVReader(func(in io.Reader) gocsv.CSVReader { - //return csv.NewReader(in) - return gocsv.LazyCSVReader(in) // Allows use of quotes in CSV - }) - - ... - - gocsv.UnmarshalFile(file, &clients) - - ... - - gocsv.SetCSVWriter(func(out io.Writer) *gocsv.SafeCSVWriter { - writer := csv.NewWriter(out) - writer.Comma = '|' - return gocsv.NewSafeCSVWriter(writer) - }) - - ... - - gocsv.MarshalFile(&clients, file) - - ... -} - -``` diff --git a/vendor/github.com/gocarina/gocsv/csv.go b/vendor/github.com/gocarina/gocsv/csv.go deleted file mode 100644 index e34819bad3..0000000000 --- a/vendor/github.com/gocarina/gocsv/csv.go +++ /dev/null @@ -1,554 +0,0 @@ -// Copyright 2014 Jonathan Picques. All rights reserved. -// Use of this source code is governed by a MIT license -// The license can be found in the LICENSE file. - -// The GoCSV package aims to provide easy CSV serialization and deserialization to the golang programming language - -package gocsv - -import ( - "bytes" - "encoding/csv" - "fmt" - "io" - "mime/multipart" - "os" - "reflect" - "strings" - "sync" -) - -// FailIfUnmatchedStructTags indicates whether it is considered an error when there is an unmatched -// struct tag. -var FailIfUnmatchedStructTags = false - -// FailIfDoubleHeaderNames indicates whether it is considered an error when a header name is repeated -// in the csv header. -var FailIfDoubleHeaderNames = false - -// ShouldAlignDuplicateHeadersWithStructFieldOrder indicates whether we should align duplicate CSV -// headers per their alignment in the struct definition. -var ShouldAlignDuplicateHeadersWithStructFieldOrder = false - -// TagName defines key in the struct field's tag to scan -var TagName = "csv" - -// TagSeparator defines seperator string for multiple csv tags in struct fields -var TagSeparator = "," - -// FieldSeperator defines how to combine parent struct with child struct -var FieldsCombiner = "." - -// Normalizer is a function that takes and returns a string. It is applied to -// struct and header field values before they are compared. It can be used to alter -// names for comparison. For instance, you could allow case insensitive matching -// or convert '-' to '_'. -type Normalizer func(string) string - -type ErrorHandler func(*csv.ParseError) bool - -// normalizeName function initially set to a nop Normalizer. -var normalizeName = DefaultNameNormalizer() - -// DefaultNameNormalizer is a nop Normalizer. -func DefaultNameNormalizer() Normalizer { return func(s string) string { return s } } - -// SetHeaderNormalizer sets the normalizer used to normalize struct and header field names. -func SetHeaderNormalizer(f Normalizer) { - normalizeName = f - // Need to clear the cache hen the header normalizer changes. - structInfoCache = sync.Map{} -} - -// -------------------------------------------------------------------------- -// CSVWriter used to format CSV - -var selfCSVWriter = DefaultCSVWriter - -// DefaultCSVWriter is the default SafeCSVWriter used to format CSV (cf. csv.NewWriter) -func DefaultCSVWriter(out io.Writer) *SafeCSVWriter { - writer := NewSafeCSVWriter(csv.NewWriter(out)) - - // As only one rune can be defined as a CSV separator, we are going to trim - // the custom tag separator and use the first rune. - if runes := []rune(strings.TrimSpace(TagSeparator)); len(runes) > 0 { - writer.Comma = runes[0] - } - - return writer -} - -// SetCSVWriter sets the SafeCSVWriter used to format CSV. -func SetCSVWriter(csvWriter func(io.Writer) *SafeCSVWriter) { - selfCSVWriter = csvWriter -} - -func getCSVWriter(out io.Writer) *SafeCSVWriter { - return selfCSVWriter(out) -} - -// -------------------------------------------------------------------------- -// CSVReader used to parse CSV - -var selfCSVReader = DefaultCSVReader - -// DefaultCSVReader is the default CSV reader used to parse CSV (cf. csv.NewReader) -func DefaultCSVReader(in io.Reader) CSVReader { - return csv.NewReader(in) -} - -// LazyCSVReader returns a lazy CSV reader, with LazyQuotes and TrimLeadingSpace. -func LazyCSVReader(in io.Reader) CSVReader { - csvReader := csv.NewReader(in) - csvReader.LazyQuotes = true - csvReader.TrimLeadingSpace = true - return csvReader -} - -// SetCSVReader sets the CSV reader used to parse CSV. -func SetCSVReader(csvReader func(io.Reader) CSVReader) { - selfCSVReader = csvReader -} - -func getCSVReader(in io.Reader) CSVReader { - return selfCSVReader(in) -} - -// -------------------------------------------------------------------------- -// Marshal functions - -// MarshalFile saves the interface as CSV in the file. -func MarshalFile(in interface{}, file *os.File) (err error) { - return Marshal(in, file) -} - -// MarshalString returns the CSV string from the interface. -func MarshalString(in interface{}) (out string, err error) { - bufferString := bytes.NewBufferString(out) - if err := Marshal(in, bufferString); err != nil { - return "", err - } - return bufferString.String(), nil -} - -// MarshalStringWithoutHeaders returns the CSV string from the interface. -func MarshalStringWithoutHeaders(in interface{}) (out string, err error) { - bufferString := bytes.NewBufferString(out) - if err := MarshalWithoutHeaders(in, bufferString); err != nil { - return "", err - } - return bufferString.String(), nil -} - -// MarshalBytes returns the CSV bytes from the interface. -func MarshalBytes(in interface{}) (out []byte, err error) { - bufferString := bytes.NewBuffer(out) - if err := Marshal(in, bufferString); err != nil { - return nil, err - } - return bufferString.Bytes(), nil -} - -// Marshal returns the CSV in writer from the interface. -func Marshal(in interface{}, out io.Writer) (err error) { - writer := getCSVWriter(out) - return writeTo(writer, in, false) -} - -// MarshalWithoutHeaders returns the CSV in writer from the interface. -func MarshalWithoutHeaders(in interface{}, out io.Writer) (err error) { - writer := getCSVWriter(out) - return writeTo(writer, in, true) -} - -// MarshalChan returns the CSV read from the channel. -func MarshalChan(c <-chan interface{}, out CSVWriter) error { - return writeFromChan(out, c, false) -} - -// MarshalChanWithoutHeaders returns the CSV read from the channel. -func MarshalChanWithoutHeaders(c <-chan interface{}, out CSVWriter) error { - return writeFromChan(out, c, true) -} - -// MarshalCSV returns the CSV in writer from the interface. -func MarshalCSV(in interface{}, out CSVWriter) (err error) { - return writeTo(out, in, false) -} - -// MarshalCSVWithoutHeaders returns the CSV in writer from the interface. -func MarshalCSVWithoutHeaders(in interface{}, out CSVWriter) (err error) { - return writeTo(out, in, true) -} - -// -------------------------------------------------------------------------- -// Unmarshal functions - -// UnmarshalFile parses the CSV from the file in the interface. -func UnmarshalFile(in *os.File, out interface{}) error { - return Unmarshal(in, out) -} - -// UnmarshalMultipartFile parses the CSV from the multipart file in the interface. -func UnmarshalMultipartFile(in *multipart.File, out interface{}) error { - return Unmarshal(convertTo(in), out) -} - -// UnmarshalFileWithErrorHandler parses the CSV from the file in the interface. -func UnmarshalFileWithErrorHandler(in *os.File, errHandler ErrorHandler, out interface{}) error { - return UnmarshalWithErrorHandler(in, errHandler, out) -} - -// UnmarshalString parses the CSV from the string in the interface. -func UnmarshalString(in string, out interface{}) error { - return Unmarshal(strings.NewReader(in), out) -} - -// UnmarshalBytes parses the CSV from the bytes in the interface. -func UnmarshalBytes(in []byte, out interface{}) error { - return Unmarshal(bytes.NewReader(in), out) -} - -// Unmarshal parses the CSV from the reader in the interface. -func Unmarshal(in io.Reader, out interface{}) error { - return readTo(newSimpleDecoderFromReader(in), out) -} - -// Unmarshal parses the CSV from the reader in the interface. -func UnmarshalWithErrorHandler(in io.Reader, errHandle ErrorHandler, out interface{}) error { - return readToWithErrorHandler(newSimpleDecoderFromReader(in), errHandle, out) -} - -// UnmarshalWithoutHeaders parses the CSV from the reader in the interface. -func UnmarshalWithoutHeaders(in io.Reader, out interface{}) error { - return readToWithoutHeaders(newSimpleDecoderFromReader(in), out) -} - -// UnmarshalCSVWithoutHeaders parses a headerless CSV with passed in CSV reader -func UnmarshalCSVWithoutHeaders(in CSVReader, out interface{}) error { - return readToWithoutHeaders(csvDecoder{in}, out) -} - -// UnmarshalDecoder parses the CSV from the decoder in the interface -func UnmarshalDecoder(in Decoder, out interface{}) error { - return readTo(in, out) -} - -// UnmarshalCSV parses the CSV from the reader in the interface. -func UnmarshalCSV(in CSVReader, out interface{}) error { - return readTo(csvDecoder{in}, out) -} - -// UnmarshalCSVToMap parses a CSV of 2 columns into a map. -func UnmarshalCSVToMap(in CSVReader, out interface{}) error { - decoder := NewSimpleDecoderFromCSVReader(in) - header, err := decoder.GetCSVRow() - if err != nil { - return err - } - if len(header) != 2 { - return fmt.Errorf("maps can only be created for csv of two columns") - } - outValue, outType := getConcreteReflectValueAndType(out) - if outType.Kind() != reflect.Map { - return fmt.Errorf("cannot use " + outType.String() + ", only map supported") - } - keyType := outType.Key() - valueType := outType.Elem() - outValue.Set(reflect.MakeMap(outType)) - for { - key := reflect.New(keyType) - value := reflect.New(valueType) - line, err := decoder.GetCSVRow() - if err == io.EOF { - break - } else if err != nil { - return err - } - if err := setField(key, line[0], false); err != nil { - return err - } - if err := setField(value, line[1], false); err != nil { - return err - } - outValue.SetMapIndex(key.Elem(), value.Elem()) - } - return nil -} - -// UnmarshalToChan parses the CSV from the reader and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalToChan(in io.Reader, c interface{}) error { - if c == nil { - return fmt.Errorf("goscv: channel is %v", c) - } - return readEach(newSimpleDecoderFromReader(in), nil, c) -} - -// UnmarshalToChanWithErrorHandler parses the CSV from the reader in the interface. -func UnmarshalToChanWithErrorHandler(in io.Reader, errorHandler ErrorHandler, c interface{}) error { - if c == nil { - return fmt.Errorf("goscv: channel is %v", c) - } - return readEach(newSimpleDecoderFromReader(in), errorHandler, c) -} - -// UnmarshalToChanWithoutHeaders parses the CSV from the reader and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalToChanWithoutHeaders(in io.Reader, c interface{}) error { - if c == nil { - return fmt.Errorf("goscv: channel is %v", c) - } - return readEachWithoutHeaders(newSimpleDecoderFromReader(in), c) -} - -// UnmarshalDecoderToChan parses the CSV from the decoder and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalDecoderToChan(in SimpleDecoder, c interface{}) error { - if c == nil { - return fmt.Errorf("goscv: channel is %v", c) - } - return readEach(in, nil, c) -} - -// UnmarshalStringToChan parses the CSV from the string and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalStringToChan(in string, c interface{}) error { - return UnmarshalToChan(strings.NewReader(in), c) -} - -// UnmarshalBytesToChan parses the CSV from the bytes and send each value in the chan c. -// The channel must have a concrete type. -func UnmarshalBytesToChan(in []byte, c interface{}) error { - return UnmarshalToChan(bytes.NewReader(in), c) -} - -// UnmarshalToCallback parses the CSV from the reader and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalToCallback(in io.Reader, f interface{}) error { - valueFunc := reflect.ValueOf(f) - t := reflect.TypeOf(f) - if t.NumIn() != 1 { - return fmt.Errorf("the given function must have exactly one parameter") - } - cerr := make(chan error) - c := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, t.In(0)), 0) - go func() { - cerr <- UnmarshalToChan(in, c.Interface()) - }() - for { - select { - case err := <-cerr: - return err - default: - } - v, notClosed := c.Recv() - if !notClosed || v.Interface() == nil { - break - } - callResults := valueFunc.Call([]reflect.Value{v}) - // if last returned value from Call() is an error, return it - if len(callResults) > 0 { - if err, ok := callResults[len(callResults)-1].Interface().(error); ok { - return err - } - } - } - return <-cerr -} - -// UnmarshalDecoderToCallback parses the CSV from the decoder and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalDecoderToCallback(in SimpleDecoder, f interface{}) error { - valueFunc := reflect.ValueOf(f) - t := reflect.TypeOf(f) - if t.NumIn() != 1 { - return fmt.Errorf("the given function must have exactly one parameter") - } - cerr := make(chan error) - c := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, t.In(0)), 0) - go func() { - cerr <- UnmarshalDecoderToChan(in, c.Interface()) - }() - for { - select { - case err := <-cerr: - return err - default: - } - v, notClosed := c.Recv() - if !notClosed || v.Interface() == nil { - break - } - valueFunc.Call([]reflect.Value{v}) - } - return <-cerr -} - -// UnmarshalBytesToCallback parses the CSV from the bytes and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalBytesToCallback(in []byte, f interface{}) error { - return UnmarshalToCallback(bytes.NewReader(in), f) -} - -// UnmarshalStringToCallback parses the CSV from the string and send each value to the given func f. -// The func must look like func(Struct). -func UnmarshalStringToCallback(in string, c interface{}) (err error) { - return UnmarshalToCallback(strings.NewReader(in), c) -} - -// UnmarshalToCallbackWithError parses the CSV from the reader and -// send each value to the given func f. -// -// If func returns error, it will stop processing, drain the -// parser and propagate the error to caller. -// -// The func must look like func(Struct) error. -func UnmarshalToCallbackWithError(in io.Reader, f interface{}) error { - valueFunc := reflect.ValueOf(f) - t := reflect.TypeOf(f) - if t.NumIn() != 1 { - return fmt.Errorf("the given function must have exactly one parameter") - } - if t.NumOut() != 1 { - return fmt.Errorf("the given function must have exactly one return value") - } - if !isErrorType(t.Out(0)) { - return fmt.Errorf("the given function must only return error") - } - - cerr := make(chan error) - c := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, t.In(0)), 0) - go func() { - cerr <- UnmarshalToChan(in, c.Interface()) - }() - - var fErr error - for { - select { - case err := <-cerr: - if err != nil { - return err - } - return fErr - default: - } - v, notClosed := c.Recv() - if !notClosed || v.Interface() == nil { - if err := <-cerr; err != nil { - fErr = err - } - break - } - - // callback f has already returned an error, stop processing but keep draining the chan c - if fErr != nil { - continue - } - - results := valueFunc.Call([]reflect.Value{v}) - - // If the callback f returns an error, stores it and returns it in future. - errValue := results[0].Interface() - if errValue != nil { - fErr = errValue.(error) - } - } - return fErr -} - -// UnmarshalBytesToCallbackWithError parses the CSV from the bytes and -// send each value to the given func f. -// -// If func returns error, it will stop processing, drain the -// parser and propagate the error to caller. -// -// The func must look like func(Struct) error. -func UnmarshalBytesToCallbackWithError(in []byte, f interface{}) error { - return UnmarshalToCallbackWithError(bytes.NewReader(in), f) -} - -// UnmarshalStringToCallbackWithError parses the CSV from the string and -// send each value to the given func f. -// -// If func returns error, it will stop processing, drain the -// parser and propagate the error to caller. -// -// The func must look like func(Struct) error. -func UnmarshalStringToCallbackWithError(in string, c interface{}) (err error) { - return UnmarshalToCallbackWithError(strings.NewReader(in), c) -} - -// CSVToMap creates a simple map from a CSV of 2 columns. -func CSVToMap(in io.Reader) (map[string]string, error) { - decoder := newSimpleDecoderFromReader(in) - header, err := decoder.GetCSVRow() - if err != nil { - return nil, err - } - if len(header) != 2 { - return nil, fmt.Errorf("maps can only be created for csv of two columns") - } - m := make(map[string]string) - for { - line, err := decoder.GetCSVRow() - if err == io.EOF { - break - } else if err != nil { - return nil, err - } - m[line[0]] = line[1] - } - return m, nil -} - -// CSVToMaps takes a reader and returns an array of dictionaries, using the header row as the keys -func CSVToMaps(reader io.Reader) ([]map[string]string, error) { - r := getCSVReader(reader) - rows := []map[string]string{} - var header []string - for { - record, err := r.Read() - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - if header == nil { - header = record - } else { - dict := map[string]string{} - for i := range header { - dict[header[i]] = record[i] - } - rows = append(rows, dict) - } - } - return rows, nil -} - -// CSVToChanMaps parses the CSV from the reader and send a dictionary in the chan c, using the header row as the keys. -func CSVToChanMaps(reader io.Reader, c chan<- map[string]string) error { - r := csv.NewReader(reader) - var header []string - for { - record, err := r.Read() - if err == io.EOF { - break - } - if err != nil { - return err - } - if header == nil { - header = record - } else { - dict := map[string]string{} - for i := range header { - dict[header[i]] = record[i] - } - c <- dict - } - } - return nil -} diff --git a/vendor/github.com/gocarina/gocsv/decode.go b/vendor/github.com/gocarina/gocsv/decode.go deleted file mode 100644 index e91c595339..0000000000 --- a/vendor/github.com/gocarina/gocsv/decode.go +++ /dev/null @@ -1,539 +0,0 @@ -package gocsv - -import ( - "encoding/csv" - "errors" - "fmt" - "io" - "mime/multipart" - "reflect" -) - -var ( - ErrUnmatchedStructTags = errors.New("unmatched struct tags") - ErrDoubleHeaderNames = errors.New("double header names") -) - -// Decoder . -type Decoder interface { - GetCSVRows() ([][]string, error) -} - -// SimpleDecoder . -type SimpleDecoder interface { - GetCSVRow() ([]string, error) - GetCSVRows() ([][]string, error) -} - -type CSVReader interface { - Read() ([]string, error) - ReadAll() ([][]string, error) -} - -type csvDecoder struct { - CSVReader -} - -func newSimpleDecoderFromReader(r io.Reader) SimpleDecoder { - return csvDecoder{getCSVReader(r)} -} - -var ( - ErrEmptyCSVFile = errors.New("empty csv file given") - ErrNoStructTags = errors.New("no csv struct tags found") -) - -// NewSimpleDecoderFromCSVReader creates a SimpleDecoder, which may be passed -// to the UnmarshalDecoder* family of functions, from a CSV reader. Note that -// encoding/csv.Reader implements CSVReader, so you can pass one of those -// directly here. -func NewSimpleDecoderFromCSVReader(r CSVReader) SimpleDecoder { - return csvDecoder{r} -} - -func (c csvDecoder) GetCSVRows() ([][]string, error) { - return c.ReadAll() -} - -func (c csvDecoder) GetCSVRow() ([]string, error) { - return c.Read() -} - -func mismatchStructFields(structInfo []fieldInfo, headers []string) []string { - missing := make([]string, 0) - if len(structInfo) == 0 { - return missing - } - - headerMap := make(map[string]struct{}, len(headers)) - for idx := range headers { - headerMap[headers[idx]] = struct{}{} - } - - for _, info := range structInfo { - found := false - for _, key := range info.keys { - if _, ok := headerMap[key]; ok { - found = true - break - } - } - if !found { - missing = append(missing, info.keys...) - } - } - return missing -} - -func mismatchHeaderFields(structInfo []fieldInfo, headers []string) []string { - missing := make([]string, 0) - if len(headers) == 0 { - return missing - } - - keyMap := make(map[string]struct{}) - for _, info := range structInfo { - for _, key := range info.keys { - keyMap[key] = struct{}{} - } - } - - for _, header := range headers { - if _, ok := keyMap[header]; !ok { - missing = append(missing, header) - } - } - return missing -} - -func maybeMissingStructFields(structInfo []fieldInfo, headers []string) error { - missing := mismatchStructFields(structInfo, headers) - if len(missing) != 0 { - return fmt.Errorf("found unmatched struct field with tags %v, %w", missing, ErrUnmatchedStructTags) - } - return nil -} - -// Check that no header name is repeated twice -func maybeDoubleHeaderNames(headers []string) error { - headerMap := make(map[string]bool, len(headers)) - for _, v := range headers { - if _, ok := headerMap[v]; ok { - return fmt.Errorf("repeated header name: %v, %w", v, ErrDoubleHeaderNames) - } - headerMap[v] = true - } - return nil -} - -// apply normalizer func to headers -func normalizeHeaders(headers []string) []string { - out := make([]string, len(headers)) - for i, h := range headers { - out[i] = normalizeName(h) - } - return out -} - -// convertTo converts multipart file to io.Reader -func convertTo(file *multipart.File) io.Reader { - return io.Reader(*file) -} - -func readTo(decoder Decoder, out interface{}) error { - return readToWithErrorHandler(decoder, nil, out) -} - -func readToWithErrorHandler(decoder Decoder, errHandler ErrorHandler, out interface{}) error { - outValue, outType := getConcreteReflectValueAndType(out) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureOutType(outType); err != nil { - return err - } - outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureOutInnerType(outInnerType); err != nil { - return err - } - csvRows, err := decoder.GetCSVRows() // Get the CSV csvRows - if err != nil { - return err - } - if len(csvRows) == 0 { - return ErrEmptyCSVFile - } - if err := ensureOutCapacity(&outValue, len(csvRows)); err != nil { // Ensure the container is big enough to hold the CSV content - return err - } - outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations - if len(outInnerStructInfo.Fields) == 0 { - return ErrNoStructTags - } - - headers := normalizeHeaders(csvRows[0]) - body := csvRows[1:] - - csvHeadersLabels := make(map[int]*fieldInfo, len(outInnerStructInfo.Fields)) // Used to store the correspondance header <-> position in CSV - - headerCount := map[string]int{} - for i, csvColumnHeader := range headers { - curHeaderCount := headerCount[csvColumnHeader] - if fieldInfo := getCSVFieldPosition(csvColumnHeader, outInnerStructInfo, curHeaderCount); fieldInfo != nil { - csvHeadersLabels[i] = fieldInfo - if ShouldAlignDuplicateHeadersWithStructFieldOrder { - curHeaderCount++ - headerCount[csvColumnHeader] = curHeaderCount - } - } - } - - if FailIfUnmatchedStructTags { - if err := maybeMissingStructFields(outInnerStructInfo.Fields, headers); err != nil { - return err - } - } - if FailIfDoubleHeaderNames { - if err := maybeDoubleHeaderNames(headers); err != nil { - return err - } - } - - var withFieldsOK bool - var fieldTypeUnmarshallerWithKeys TypeUnmarshalCSVWithFields - - for i, csvRow := range body { - objectIface := reflect.New(outValue.Index(i).Type()).Interface() - outInner := createNewOutInner(outInnerWasPointer, outInnerType) - for j, csvColumnContent := range csvRow { - if outInner.CanInterface() { - fieldTypeUnmarshallerWithKeys, withFieldsOK = objectIface.(TypeUnmarshalCSVWithFields) - if withFieldsOK { - if err := fieldTypeUnmarshallerWithKeys.UnmarshalCSVWithFields(headers[j], csvColumnContent); err != nil { - parseError := csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - return &parseError - } - continue - } - } - - if fieldInfo, ok := csvHeadersLabels[j]; ok { // Position found accordingly to header name - value := csvColumnContent - if value == "" { - value = fieldInfo.defaultValue - } - if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, value, fieldInfo.omitEmpty); err != nil { // Set field of struct - parseError := csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - if errHandler == nil || !errHandler(&parseError) { - return &parseError - } - } - } - } - - if withFieldsOK { - reflectedObject := reflect.ValueOf(objectIface) - outInner = reflectedObject.Elem() - } - - outValue.Index(i).Set(outInner) - } - return nil -} - -func readEach(decoder SimpleDecoder, errHandler ErrorHandler, c interface{}) error { - outValue, outType := getConcreteReflectValueAndType(c) // Get the concrete type (not pointer) - if outType.Kind() != reflect.Chan { - return fmt.Errorf("cannot use %v with type %s, only channel supported", c, outType) - } - defer outValue.Close() - - headers, err := decoder.GetCSVRow() - if err != nil { - return err - } - headers = normalizeHeaders(headers) - - outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureOutInnerType(outInnerType); err != nil { - return err - } - outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations - if len(outInnerStructInfo.Fields) == 0 { - return ErrNoStructTags - } - csvHeadersLabels := make(map[int]*fieldInfo, len(outInnerStructInfo.Fields)) // Used to store the correspondance header <-> position in CSV - headerCount := map[string]int{} - for i, csvColumnHeader := range headers { - curHeaderCount := headerCount[csvColumnHeader] - if fieldInfo := getCSVFieldPosition(csvColumnHeader, outInnerStructInfo, curHeaderCount); fieldInfo != nil { - csvHeadersLabels[i] = fieldInfo - if ShouldAlignDuplicateHeadersWithStructFieldOrder { - curHeaderCount++ - headerCount[csvColumnHeader] = curHeaderCount - } - } - } - if err := maybeMissingStructFields(outInnerStructInfo.Fields, headers); err != nil { - if FailIfUnmatchedStructTags { - return err - } - } - if FailIfDoubleHeaderNames { - if err := maybeDoubleHeaderNames(headers); err != nil { - return err - } - } - - var withFieldsOK bool - var fieldTypeUnmarshallerWithKeys TypeUnmarshalCSVWithFields - - i := 0 - for { - objectIface := reflect.New(outValue.Type().Elem()).Interface() - line, err := decoder.GetCSVRow() - if err == io.EOF { - break - } else if err != nil { - return err - } - outInner := createNewOutInner(outInnerWasPointer, outInnerType) - for j, csvColumnContent := range line { - - if outInner.CanInterface() { - fieldTypeUnmarshallerWithKeys, withFieldsOK = objectIface.(TypeUnmarshalCSVWithFields) - if withFieldsOK { - if err := fieldTypeUnmarshallerWithKeys.UnmarshalCSVWithFields(headers[j], csvColumnContent); err != nil { - parseError := csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - return &parseError - } - - continue - } - } - - if fieldInfo, ok := csvHeadersLabels[j]; ok { // Position found accordingly to header name - - value := csvColumnContent - if value == "" { - value = fieldInfo.defaultValue - } - - if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, value, fieldInfo.omitEmpty); err != nil { // Set field of struct - parseError := &csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - - if errHandler == nil || !errHandler(parseError) { - return parseError - } - } - } - } - - if withFieldsOK { - reflectedObject := reflect.ValueOf(objectIface) - outInner = reflectedObject.Elem() - } - - outValue.Send(outInner) - i++ - } - return nil -} - -func readEachWithoutHeaders(decoder SimpleDecoder, c interface{}) error { - outValue, outType := getConcreteReflectValueAndType(c) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureOutType(outType); err != nil { - return err - } - defer outValue.Close() - - outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureOutInnerType(outInnerType); err != nil { - return err - } - outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations - if len(outInnerStructInfo.Fields) == 0 { - return ErrNoStructTags - } - - i := 0 - for { - line, err := decoder.GetCSVRow() - if err == io.EOF { - break - } else if err != nil { - return err - } - outInner := createNewOutInner(outInnerWasPointer, outInnerType) - for j, csvColumnContent := range line { - fieldInfo := outInnerStructInfo.Fields[j] - if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct - return &csv.ParseError{ - Line: i + 2, //add 2 to account for the header & 0-indexing of arrays - Column: j + 1, - Err: err, - } - } - } - outValue.Send(outInner) - i++ - } - return nil -} - -func readToWithoutHeaders(decoder Decoder, out interface{}) error { - outValue, outType := getConcreteReflectValueAndType(out) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureOutType(outType); err != nil { - return err - } - outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureOutInnerType(outInnerType); err != nil { - return err - } - csvRows, err := decoder.GetCSVRows() // Get the CSV csvRows - if err != nil { - return err - } - if len(csvRows) == 0 { - return ErrEmptyCSVFile - } - if err := ensureOutCapacity(&outValue, len(csvRows)+1); err != nil { // Ensure the container is big enough to hold the CSV content - return err - } - outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations - if len(outInnerStructInfo.Fields) == 0 { - return ErrNoStructTags - } - - for i, csvRow := range csvRows { - outInner := createNewOutInner(outInnerWasPointer, outInnerType) - for j, csvColumnContent := range csvRow { - fieldInfo := outInnerStructInfo.Fields[j] - if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct - return &csv.ParseError{ - Line: i + 1, - Column: j + 1, - Err: err, - } - } - } - outValue.Index(i).Set(outInner) - } - - return nil -} - -// Check if the outType is an array or a slice -func ensureOutType(outType reflect.Type) error { - switch outType.Kind() { - case reflect.Slice: - fallthrough - case reflect.Chan: - fallthrough - case reflect.Array: - return nil - } - return fmt.Errorf("cannot use " + outType.String() + ", only slice or array supported") -} - -// Check if the outInnerType is of type struct -func ensureOutInnerType(outInnerType reflect.Type) error { - switch outInnerType.Kind() { - case reflect.Struct: - return nil - } - return fmt.Errorf("cannot use " + outInnerType.String() + ", only struct supported") -} - -func ensureOutCapacity(out *reflect.Value, csvLen int) error { - switch out.Kind() { - case reflect.Array: - if out.Len() < csvLen-1 { // Array is not big enough to hold the CSV content (arrays are not addressable) - return fmt.Errorf("array capacity problem: cannot store %d %s in %s", csvLen-1, out.Type().Elem().String(), out.Type().String()) - } - case reflect.Slice: - if !out.CanAddr() && out.Len() < csvLen-1 { // Slice is not big enough tho hold the CSV content and is not addressable - return fmt.Errorf("slice capacity problem and is not addressable (did you forget &?)") - } else if out.CanAddr() && out.Len() < csvLen-1 { - out.Set(reflect.MakeSlice(out.Type(), csvLen-1, csvLen-1)) // Slice is not big enough, so grows it - } - } - return nil -} - -func getCSVFieldPosition(key string, structInfo *structInfo, curHeaderCount int) *fieldInfo { - matchedFieldCount := 0 - for _, field := range structInfo.Fields { - if field.matchesKey(key) { - if matchedFieldCount >= curHeaderCount { - return &field - } - matchedFieldCount++ - } - } - return nil -} - -func createNewOutInner(outInnerWasPointer bool, outInnerType reflect.Type) reflect.Value { - if outInnerWasPointer { - return reflect.New(outInnerType) - } - return reflect.New(outInnerType).Elem() -} - -func setInnerField(outInner *reflect.Value, outInnerWasPointer bool, index []int, value string, omitEmpty bool) error { - oi := *outInner - if outInnerWasPointer { - // initialize nil pointer - if oi.IsNil() { - if err := setField(oi, "", omitEmpty); err != nil { - return err - } - } - oi = outInner.Elem() - } - - if oi.Kind() == reflect.Slice || oi.Kind() == reflect.Array { - i := index[0] - - // grow slice when needed - if i >= oi.Cap() { - newcap := oi.Cap() + oi.Cap()/2 - if newcap < 4 { - newcap = 4 - } - newoi := reflect.MakeSlice(oi.Type(), oi.Len(), newcap) - reflect.Copy(newoi, oi) - oi.Set(newoi) - } - if i >= oi.Len() { - oi.SetLen(i + 1) - } - - item := oi.Index(i) - if len(index) > 1 { - return setInnerField(&item, false, index[1:], value, omitEmpty) - } - return setField(item, value, omitEmpty) - } - - // because pointers can be nil need to recurse one index at a time and perform nil check - if len(index) > 1 { - nextField := oi.Field(index[0]) - return setInnerField(&nextField, nextField.Kind() == reflect.Ptr, index[1:], value, omitEmpty) - } - return setField(oi.FieldByIndex(index), value, omitEmpty) -} diff --git a/vendor/github.com/gocarina/gocsv/encode.go b/vendor/github.com/gocarina/gocsv/encode.go deleted file mode 100644 index a7c0e720ef..0000000000 --- a/vendor/github.com/gocarina/gocsv/encode.go +++ /dev/null @@ -1,169 +0,0 @@ -package gocsv - -import ( - "errors" - "fmt" - "io" - "reflect" -) - -var ( - ErrChannelIsClosed = errors.New("channel is closed") -) - -type encoder struct { - out io.Writer -} - -func newEncoder(out io.Writer) *encoder { - return &encoder{out} -} - -func writeFromChan(writer CSVWriter, c <-chan interface{}, omitHeaders bool) error { - // Get the first value. It wil determine the header structure. - firstValue, ok := <-c - if !ok { - return ErrChannelIsClosed - } - inValue, inType := getConcreteReflectValueAndType(firstValue) // Get the concrete type - if err := ensureStructOrPtr(inType); err != nil { - return err - } - inInnerWasPointer := inType.Kind() == reflect.Ptr - inInnerStructInfo := getStructInfo(inType) // Get the inner struct info to get CSV annotations - csvHeadersLabels := make([]string, len(inInnerStructInfo.Fields)) - for i, fieldInfo := range inInnerStructInfo.Fields { // Used to write the header (first line) in CSV - csvHeadersLabels[i] = fieldInfo.getFirstKey() - } - if !omitHeaders { - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - } - write := func(val reflect.Value) error { - for j, fieldInfo := range inInnerStructInfo.Fields { - csvHeadersLabels[j] = "" - inInnerFieldValue, err := getInnerField(val, inInnerWasPointer, fieldInfo.IndexChain) // Get the correct field header <-> position - if err != nil { - return err - } - csvHeadersLabels[j] = inInnerFieldValue - } - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - return nil - } - if err := write(inValue); err != nil { - return err - } - for v := range c { - val, _ := getConcreteReflectValueAndType(v) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureStructOrPtr(inType); err != nil { - return err - } - if err := write(val); err != nil { - return err - } - } - writer.Flush() - return writer.Error() -} - -func writeTo(writer CSVWriter, in interface{}, omitHeaders bool) error { - inValue, inType := getConcreteReflectValueAndType(in) // Get the concrete type (not pointer) (Slice or Array) - if err := ensureInType(inType); err != nil { - return err - } - inInnerWasPointer, inInnerType := getConcreteContainerInnerType(inType) // Get the concrete inner type (not pointer) (Container<"?">) - if err := ensureInInnerType(inInnerType); err != nil { - return err - } - inInnerStructInfo := getStructInfo(inInnerType) // Get the inner struct info to get CSV annotations - csvHeadersLabels := make([]string, len(inInnerStructInfo.Fields)) - for i, fieldInfo := range inInnerStructInfo.Fields { // Used to write the header (first line) in CSV - csvHeadersLabels[i] = fieldInfo.getFirstKey() - } - if !omitHeaders { - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - } - inLen := inValue.Len() - for i := 0; i < inLen; i++ { // Iterate over container rows - for j, fieldInfo := range inInnerStructInfo.Fields { - csvHeadersLabels[j] = "" - inInnerFieldValue, err := getInnerField(inValue.Index(i), inInnerWasPointer, fieldInfo.IndexChain) // Get the correct field header <-> position - if err != nil { - return err - } - csvHeadersLabels[j] = inInnerFieldValue - } - if err := writer.Write(csvHeadersLabels); err != nil { - return err - } - } - writer.Flush() - return writer.Error() -} - -func ensureStructOrPtr(t reflect.Type) error { - switch t.Kind() { - case reflect.Struct: - fallthrough - case reflect.Ptr: - return nil - } - return fmt.Errorf("cannot use " + t.String() + ", only slice or array supported") -} - -// Check if the inType is an array or a slice -func ensureInType(outType reflect.Type) error { - switch outType.Kind() { - case reflect.Slice: - fallthrough - case reflect.Array: - return nil - } - return fmt.Errorf("cannot use " + outType.String() + ", only slice or array supported") -} - -// Check if the inInnerType is of type struct -func ensureInInnerType(outInnerType reflect.Type) error { - switch outInnerType.Kind() { - case reflect.Struct: - return nil - } - return fmt.Errorf("cannot use " + outInnerType.String() + ", only struct supported") -} - -func getInnerField(outInner reflect.Value, outInnerWasPointer bool, index []int) (string, error) { - oi := outInner - if outInnerWasPointer { - if oi.IsNil() { - return "", nil - } - oi = outInner.Elem() - } - - if oi.Kind() == reflect.Slice || oi.Kind() == reflect.Array { - i := index[0] - - if i >= oi.Len() { - return "", nil - } - - item := oi.Index(i) - if len(index) > 1 { - return getInnerField(item, false, index[1:]) - } - return getFieldAsString(item) - } - - // because pointers can be nil need to recurse one index at a time and perform nil check - if len(index) > 1 { - nextField := oi.Field(index[0]) - return getInnerField(nextField, nextField.Kind() == reflect.Ptr, index[1:]) - } - return getFieldAsString(oi.FieldByIndex(index)) -} diff --git a/vendor/github.com/gocarina/gocsv/reflect.go b/vendor/github.com/gocarina/gocsv/reflect.go deleted file mode 100644 index 31c72f7952..0000000000 --- a/vendor/github.com/gocarina/gocsv/reflect.go +++ /dev/null @@ -1,266 +0,0 @@ -package gocsv - -import ( - "fmt" - "reflect" - "strconv" - "strings" - "sync" -) - -// -------------------------------------------------------------------------- -// Reflection helpers - -type structInfo struct { - Fields []fieldInfo -} - -// fieldInfo is a struct field that should be mapped to a CSV column, or vice-versa -// Each IndexChain element before the last is the index of an the embedded struct field -// that defines Key as a tag -type fieldInfo struct { - keys []string - omitEmpty bool - IndexChain []int - defaultValue string - partial bool -} - -func (f fieldInfo) getFirstKey() string { - return f.keys[0] -} - -func (f fieldInfo) matchesKey(key string) bool { - for _, k := range f.keys { - if key == k || strings.TrimSpace(key) == k || (f.partial && strings.Contains(key, k)) || removeZeroWidthChars(key) == k { - return true - } - } - return false -} - -// zwchs is Zero Width Characters map -var zwchs = map[rune]struct{}{ - '\u200B': {}, // zero width space (U+200B) - '\uFEFF': {}, // zero width no-break space (U+FEFF) - '\u200D': {}, // zero width joiner (U+200D) - '\u200C': {}, // zero width non-joiner (U+200C) -} - -func removeZeroWidthChars(s string) string { - return strings.Map(func(r rune) rune { - if _, ok := zwchs[r]; ok { - return -1 - } - return r - }, s) -} - -var structInfoCache sync.Map -var structMap = make(map[reflect.Type]*structInfo) -var structMapMutex sync.RWMutex - -func getStructInfo(rType reflect.Type) *structInfo { - stInfo, ok := structInfoCache.Load(rType) - if ok { - return stInfo.(*structInfo) - } - - fieldsList := getFieldInfos(rType, []int{}, []string{}) - stInfo = &structInfo{fieldsList} - structInfoCache.Store(rType, stInfo) - - return stInfo.(*structInfo) -} - -func getFieldInfos(rType reflect.Type, parentIndexChain []int, parentKeys []string) []fieldInfo { - fieldsCount := rType.NumField() - fieldsList := make([]fieldInfo, 0, fieldsCount) - for i := 0; i < fieldsCount; i++ { - field := rType.Field(i) - if field.PkgPath != "" { - continue - } - - var cpy = make([]int, len(parentIndexChain)) - copy(cpy, parentIndexChain) - indexChain := append(cpy, i) - - var currFieldInfo *fieldInfo - if !field.Anonymous { - filteredTags := []string{} - currFieldInfo, filteredTags = filterTags(TagName, indexChain, field) - - if len(filteredTags) == 1 && filteredTags[0] == "-" { - // ignore nested structs with - tag - continue - } else if len(filteredTags) > 0 && filteredTags[0] != "" { - currFieldInfo.keys = filteredTags - } else { - currFieldInfo.keys = []string{normalizeName(field.Name)} - } - - if len(parentKeys) > 0 && currFieldInfo != nil { - // create cartesian product of keys - // eg: parent keys x field keys - keys := make([]string, 0, len(parentKeys)*len(currFieldInfo.keys)) - for _, pkey := range parentKeys { - for _, ckey := range currFieldInfo.keys { - keys = append(keys, normalizeName(fmt.Sprintf("%s%s%s", pkey, FieldsCombiner, ckey))) - } - currFieldInfo.keys = keys - } - } - } - - // handle struct - fieldType := field.Type - // if the field is a pointer, follow the pointer - if fieldType.Kind() == reflect.Ptr { - fieldType = fieldType.Elem() - } - // if the field is a struct, create a fieldInfo for each of its fields - if fieldType.Kind() == reflect.Struct { - // Structs that implement any of the text or CSV marshaling methods - // should result in one value and not have their fields exposed - if !(canMarshal(fieldType)) { - // if the field is an embedded struct, pass along parent keys - keys := parentKeys - if currFieldInfo != nil { - keys = currFieldInfo.keys - } - fieldsList = append(fieldsList, getFieldInfos(fieldType, indexChain, keys)...) - continue - } - } - - // if the field is an embedded struct, ignore the csv tag - if currFieldInfo == nil { - continue - } - - if field.Type.Kind() == reflect.Slice || field.Type.Kind() == reflect.Array { - var arrayLength = -1 - // if the field is a slice or an array, see if it has a `csv[n]` tag - if arrayTag, ok := field.Tag.Lookup(TagName + "[]"); ok { - arrayLength, _ = strconv.Atoi(arrayTag) - } - - // slices or arrays of Struct get special handling - if field.Type.Elem().Kind() == reflect.Struct { - fieldInfos := getFieldInfos(field.Type.Elem(), []int{}, []string{}) - - // if no special csv[] tag was supplied, just include the field directly - if arrayLength == -1 { - fieldsList = append(fieldsList, *currFieldInfo) - } else { - // When the field is a slice/array of structs, create a fieldInfo for each index and each field - for idx := 0; idx < arrayLength; idx++ { - // copy index chain and append array index - var cpy2 = make([]int, len(indexChain)) - copy(cpy2, indexChain) - arrayIndexChain := append(cpy2, idx) - for _, childFieldInfo := range fieldInfos { - // copy array index chain and append array index - var cpy3 = make([]int, len(arrayIndexChain)) - copy(cpy3, arrayIndexChain) - - arrayFieldInfo := fieldInfo{ - IndexChain: append(cpy3, childFieldInfo.IndexChain...), - omitEmpty: childFieldInfo.omitEmpty, - defaultValue: childFieldInfo.defaultValue, - partial: childFieldInfo.partial, - } - - // create cartesian product of keys - // eg: array field keys x struct field keys - for _, akey := range currFieldInfo.keys { - for _, fkey := range childFieldInfo.keys { - arrayFieldInfo.keys = append(arrayFieldInfo.keys, normalizeName(fmt.Sprintf("%s[%d].%s", akey, idx, fkey))) - } - } - - fieldsList = append(fieldsList, arrayFieldInfo) - } - } - } - } else if arrayLength > 0 { - // When the field is a slice/array of primitives, create a fieldInfo for each index - for idx := 0; idx < arrayLength; idx++ { - // copy index chain and append array index - var cpy2 = make([]int, len(indexChain)) - copy(cpy2, indexChain) - - arrayFieldInfo := fieldInfo{ - IndexChain: append(cpy2, idx), - omitEmpty: currFieldInfo.omitEmpty, - defaultValue: currFieldInfo.defaultValue, - partial: currFieldInfo.partial, - } - - for _, akey := range currFieldInfo.keys { - arrayFieldInfo.keys = append(arrayFieldInfo.keys, normalizeName(fmt.Sprintf("%s[%d]", akey, idx))) - } - - fieldsList = append(fieldsList, arrayFieldInfo) - } - } else { - fieldsList = append(fieldsList, *currFieldInfo) - } - } else { - fieldsList = append(fieldsList, *currFieldInfo) - } - } - return fieldsList -} - -func filterTags(tagName string, indexChain []int, field reflect.StructField) (*fieldInfo, []string) { - currFieldInfo := fieldInfo{IndexChain: indexChain} - - fieldTag := field.Tag.Get(tagName) - fieldTags := strings.Split(fieldTag, TagSeparator) - - filteredTags := []string{} - for _, fieldTagEntry := range fieldTags { - trimmedFieldTagEntry := strings.TrimSpace(fieldTagEntry) // handles cases like `csv:"foo, omitempty, default=test"` - if trimmedFieldTagEntry == "omitempty" { - currFieldInfo.omitEmpty = true - } else if strings.HasPrefix(trimmedFieldTagEntry, "partial") { - currFieldInfo.partial = true - } else if strings.HasPrefix(trimmedFieldTagEntry, "default=") { - currFieldInfo.defaultValue = strings.TrimPrefix(trimmedFieldTagEntry, "default=") - } else { - filteredTags = append(filteredTags, normalizeName(trimmedFieldTagEntry)) - } - } - - return &currFieldInfo, filteredTags -} - -func getConcreteContainerInnerType(in reflect.Type) (inInnerWasPointer bool, inInnerType reflect.Type) { - inInnerType = in.Elem() - inInnerWasPointer = false - if inInnerType.Kind() == reflect.Ptr { - inInnerWasPointer = true - inInnerType = inInnerType.Elem() - } - return inInnerWasPointer, inInnerType -} - -func getConcreteReflectValueAndType(in interface{}) (reflect.Value, reflect.Type) { - value := reflect.ValueOf(in) - if value.Kind() == reflect.Ptr { - value = value.Elem() - } - return value, value.Type() -} - -var errorInterface = reflect.TypeOf((*error)(nil)).Elem() - -func isErrorType(outType reflect.Type) bool { - if outType.Kind() != reflect.Interface { - return false - } - - return outType.Implements(errorInterface) -} diff --git a/vendor/github.com/gocarina/gocsv/safe_csv.go b/vendor/github.com/gocarina/gocsv/safe_csv.go deleted file mode 100644 index 858b078165..0000000000 --- a/vendor/github.com/gocarina/gocsv/safe_csv.go +++ /dev/null @@ -1,38 +0,0 @@ -package gocsv - -//Wraps around SafeCSVWriter and makes it thread safe. -import ( - "encoding/csv" - "sync" -) - -type CSVWriter interface { - Write(row []string) error - Flush() - Error() error -} - -type SafeCSVWriter struct { - *csv.Writer - m sync.Mutex -} - -func NewSafeCSVWriter(original *csv.Writer) *SafeCSVWriter { - return &SafeCSVWriter{ - Writer: original, - } -} - -//Override write -func (w *SafeCSVWriter) Write(row []string) error { - w.m.Lock() - defer w.m.Unlock() - return w.Writer.Write(row) -} - -//Override flush -func (w *SafeCSVWriter) Flush() { - w.m.Lock() - w.Writer.Flush() - w.m.Unlock() -} diff --git a/vendor/github.com/gocarina/gocsv/types.go b/vendor/github.com/gocarina/gocsv/types.go deleted file mode 100644 index be853ab7bf..0000000000 --- a/vendor/github.com/gocarina/gocsv/types.go +++ /dev/null @@ -1,489 +0,0 @@ -package gocsv - -import ( - "encoding" - "fmt" - "reflect" - "strconv" - "strings" - - "encoding/json" -) - -// -------------------------------------------------------------------------- -// Conversion interfaces - -var ( - marshalerType = reflect.TypeOf(new(TypeMarshaller)).Elem() - textMarshalerType = reflect.TypeOf(new(encoding.TextMarshaler)).Elem() - unmarshalerType = reflect.TypeOf(new(TypeUnmarshaller)).Elem() - unmarshalCSVWithFieldsType = reflect.TypeOf(new(TypeUnmarshalCSVWithFields)).Elem() -) - -// TypeMarshaller is implemented by any value that has a MarshalCSV method -// This converter is used to convert the value to it string representation -type TypeMarshaller interface { - MarshalCSV() (string, error) -} - -// TypeUnmarshaller is implemented by any value that has an UnmarshalCSV method -// This converter is used to convert a string to your value representation of that string -type TypeUnmarshaller interface { - UnmarshalCSV(string) error -} - -// TypeUnmarshalCSVWithFields can be implemented on whole structs to allow for whole structures to customized internal vs one off fields -type TypeUnmarshalCSVWithFields interface { - UnmarshalCSVWithFields(key, value string) error -} - -// NoUnmarshalFuncError is the custom error type to be raised in case there is no unmarshal function defined on type -type NoUnmarshalFuncError struct { - t reflect.Type -} - -func (e NoUnmarshalFuncError) Error() string { - return "No known conversion from string to " + e.t.Name() + ", it does not implement TypeUnmarshaller" -} - -// NoMarshalFuncError is the custom error type to be raised in case there is no marshal function defined on type -type NoMarshalFuncError struct { - ty reflect.Type -} - -func (e NoMarshalFuncError) Error() string { - return "No known conversion from " + e.ty.String() + " to string, " + e.ty.String() + " does not implement TypeMarshaller nor Stringer" -} - -// -------------------------------------------------------------------------- -// Conversion helpers - -func toString(in interface{}) (string, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - return inValue.String(), nil - case reflect.Bool: - b := inValue.Bool() - if b { - return "true", nil - } - return "false", nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return fmt.Sprintf("%v", inValue.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return fmt.Sprintf("%v", inValue.Uint()), nil - case reflect.Float32: - return strconv.FormatFloat(inValue.Float(), byte('f'), -1, 32), nil - case reflect.Float64: - return strconv.FormatFloat(inValue.Float(), byte('f'), -1, 64), nil - } - return "", fmt.Errorf("No known conversion from " + inValue.Type().String() + " to string") -} - -func toBool(in interface{}) (bool, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := inValue.String() - s = strings.TrimSpace(s) - if strings.EqualFold(s, "yes") { - return true, nil - } else if strings.EqualFold(s, "no") || s == "" { - return false, nil - } else { - return strconv.ParseBool(s) - } - case reflect.Bool: - return inValue.Bool(), nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - i := inValue.Int() - if i != 0 { - return true, nil - } - return false, nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - i := inValue.Uint() - if i != 0 { - return true, nil - } - return false, nil - case reflect.Float32, reflect.Float64: - f := inValue.Float() - if f != 0 { - return true, nil - } - return false, nil - } - return false, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to bool") -} - -func toInt(in interface{}) (int64, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := strings.TrimSpace(inValue.String()) - if s == "" { - return 0, nil - } - out := strings.SplitN(s, ".", 2) - return strconv.ParseInt(out[0], 0, 64) - case reflect.Bool: - if inValue.Bool() { - return 1, nil - } - return 0, nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return inValue.Int(), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return int64(inValue.Uint()), nil - case reflect.Float32, reflect.Float64: - return int64(inValue.Float()), nil - } - return 0, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to int") -} - -func toUint(in interface{}) (uint64, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := strings.TrimSpace(inValue.String()) - if s == "" { - return 0, nil - } - - // support the float input - if strings.Contains(s, ".") { - f, err := strconv.ParseFloat(s, 64) - if err != nil { - return 0, err - } - return uint64(f), nil - } - return strconv.ParseUint(s, 0, 64) - case reflect.Bool: - if inValue.Bool() { - return 1, nil - } - return 0, nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return uint64(inValue.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return inValue.Uint(), nil - case reflect.Float32, reflect.Float64: - return uint64(inValue.Float()), nil - } - return 0, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to uint") -} - -func toFloat(in interface{}) (float64, error) { - inValue := reflect.ValueOf(in) - - switch inValue.Kind() { - case reflect.String: - s := strings.TrimSpace(inValue.String()) - if s == "" { - return 0, nil - } - s = strings.Replace(s, ",", ".", -1) - return strconv.ParseFloat(s, 64) - case reflect.Bool: - if inValue.Bool() { - return 1, nil - } - return 0, nil - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float64(inValue.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return float64(inValue.Uint()), nil - case reflect.Float32, reflect.Float64: - return inValue.Float(), nil - } - return 0, fmt.Errorf("No known conversion from " + inValue.Type().String() + " to float") -} - -func setField(field reflect.Value, value string, omitEmpty bool) error { - if field.Kind() == reflect.Ptr { - if omitEmpty && value == "" { - return nil - } - if field.IsNil() { - field.Set(reflect.New(field.Type().Elem())) - } - field = field.Elem() - } - - switch field.Interface().(type) { - case string: - s, err := toString(value) - if err != nil { - return err - } - field.SetString(s) - case bool: - b, err := toBool(value) - if err != nil { - return err - } - field.SetBool(b) - case int, int8, int16, int32, int64: - i, err := toInt(value) - if err != nil { - return err - } - field.SetInt(i) - case uint, uint8, uint16, uint32, uint64: - ui, err := toUint(value) - if err != nil { - return err - } - field.SetUint(ui) - case float32, float64: - f, err := toFloat(value) - if err != nil { - return err - } - field.SetFloat(f) - default: - // Not a native type, check for unmarshal method - if err := unmarshall(field, value); err != nil { - if _, ok := err.(NoUnmarshalFuncError); !ok { - return err - } - // Could not unmarshal, check for kind, e.g. renamed type from basic type - switch field.Kind() { - case reflect.String: - s, err := toString(value) - if err != nil { - return err - } - field.SetString(s) - case reflect.Bool: - b, err := toBool(value) - if err != nil { - return err - } - field.SetBool(b) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - i, err := toInt(value) - if err != nil { - return err - } - field.SetInt(i) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - ui, err := toUint(value) - if err != nil { - return err - } - field.SetUint(ui) - case reflect.Float32, reflect.Float64: - f, err := toFloat(value) - if err != nil { - return err - } - field.SetFloat(f) - case reflect.Slice, reflect.Struct: - if value == "" { - return nil - } - - err := json.Unmarshal([]byte(value), field.Addr().Interface()) - if err != nil { - return err - } - default: - return err - } - } else { - return nil - } - } - return nil -} - -func getFieldAsString(field reflect.Value) (str string, err error) { - switch field.Kind() { - case reflect.Interface, reflect.Ptr: - if field.IsNil() { - return "", nil - } - return getFieldAsString(field.Elem()) - default: - // Check if field is go native type - switch field.Interface().(type) { - case string: - return field.String(), nil - case bool: - if field.Bool() { - return "true", nil - } else { - return "false", nil - } - case int, int8, int16, int32, int64: - return fmt.Sprintf("%v", field.Int()), nil - case uint, uint8, uint16, uint32, uint64: - return fmt.Sprintf("%v", field.Uint()), nil - case float32: - str, err = toString(float32(field.Float())) - if err != nil { - return str, err - } - case float64: - str, err = toString(field.Float()) - if err != nil { - return str, err - } - default: - // Not a native type, check for marshal method - str, err = marshall(field) - if err != nil { - if _, ok := err.(NoMarshalFuncError); !ok { - return str, err - } - // If not marshal method, is field compatible with/renamed from native type - switch field.Kind() { - case reflect.String: - return field.String(), nil - case reflect.Bool: - str, err = toString(field.Bool()) - if err != nil { - return str, err - } - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - str, err = toString(field.Int()) - if err != nil { - return str, err - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - str, err = toString(field.Uint()) - if err != nil { - return str, err - } - case reflect.Float32: - str, err = toString(float32(field.Float())) - if err != nil { - return str, err - } - case reflect.Float64: - str, err = toString(field.Float()) - if err != nil { - return str, err - } - case reflect.Slice: - fallthrough - case reflect.Array: - b, err := json.Marshal(field.Addr().Interface()) - if err != nil { - return str, err - } - - str = string(b) - } - } else { - return str, nil - } - } - } - return str, nil -} - -// -------------------------------------------------------------------------- -// Un/serializations helpers - -func canMarshal(t reflect.Type) bool { - // Struct that implements any of the text or CSV marshaling interfaces - if t.Implements(marshalerType) || - t.Implements(textMarshalerType) || - t.Implements(unmarshalerType) || - t.Implements(unmarshalCSVWithFieldsType) { - return true - } - - // Pointer to a struct that implements any of the text or CSV marshaling interfaces - t = reflect.PtrTo(t) - if t.Implements(marshalerType) || - t.Implements(textMarshalerType) || - t.Implements(unmarshalerType) || - t.Implements(unmarshalCSVWithFieldsType) { - return true - } - return false -} - -func unmarshall(field reflect.Value, value string) error { - dupField := field - unMarshallIt := func(finalField reflect.Value) error { - if finalField.CanInterface() { - fieldIface := finalField.Interface() - - fieldTypeUnmarshaller, ok := fieldIface.(TypeUnmarshaller) - if ok { - return fieldTypeUnmarshaller.UnmarshalCSV(value) - } - - // Otherwise try to use TextUnmarshaler - fieldTextUnmarshaler, ok := fieldIface.(encoding.TextUnmarshaler) - if ok { - return fieldTextUnmarshaler.UnmarshalText([]byte(value)) - } - } - - return NoUnmarshalFuncError{field.Type()} - } - for dupField.Kind() == reflect.Interface || dupField.Kind() == reflect.Ptr { - if dupField.IsNil() { - dupField = reflect.New(field.Type().Elem()) - field.Set(dupField) - return unMarshallIt(dupField) - } - dupField = dupField.Elem() - } - if dupField.CanAddr() { - return unMarshallIt(dupField.Addr()) - } - return NoUnmarshalFuncError{field.Type()} -} - -func marshall(field reflect.Value) (value string, err error) { - dupField := field - marshallIt := func(finalField reflect.Value) (string, error) { - if finalField.CanInterface() { - fieldIface := finalField.Interface() - - // Use TypeMarshaller when possible - fieldTypeMarhaller, ok := fieldIface.(TypeMarshaller) - if ok { - return fieldTypeMarhaller.MarshalCSV() - } - - // Otherwise try to use TextMarshaller - fieldTextMarshaler, ok := fieldIface.(encoding.TextMarshaler) - if ok { - text, err := fieldTextMarshaler.MarshalText() - return string(text), err - } - - // Otherwise try to use Stringer - fieldStringer, ok := fieldIface.(fmt.Stringer) - if ok { - return fieldStringer.String(), nil - } - } - - return value, NoMarshalFuncError{field.Type()} - } - for dupField.Kind() == reflect.Interface || dupField.Kind() == reflect.Ptr { - if dupField.IsNil() { - return value, nil - } - dupField = dupField.Elem() - } - if dupField.CanAddr() { - dupField = dupField.Addr() - } - return marshallIt(dupField) -} diff --git a/vendor/github.com/gocarina/gocsv/unmarshaller.go b/vendor/github.com/gocarina/gocsv/unmarshaller.go deleted file mode 100644 index 50d528e368..0000000000 --- a/vendor/github.com/gocarina/gocsv/unmarshaller.go +++ /dev/null @@ -1,134 +0,0 @@ -package gocsv - -import ( - "encoding/csv" - "fmt" - "reflect" -) - -// Unmarshaller is a CSV to struct unmarshaller. -type Unmarshaller struct { - reader *csv.Reader - Headers []string - fieldInfoMap []*fieldInfo - MismatchedHeaders []string - MismatchedStructFields []string - outType reflect.Type - out interface{} -} - -// NewUnmarshaller creates an unmarshaller from a csv.Reader and a struct. -func NewUnmarshaller(reader *csv.Reader, out interface{}) (*Unmarshaller, error) { - headers, err := reader.Read() - if err != nil { - return nil, err - } - headers = normalizeHeaders(headers) - - um := &Unmarshaller{reader: reader, outType: reflect.TypeOf(out)} - err = validate(um, out, headers) - if err != nil { - return nil, err - } - return um, nil -} - -// Read returns an interface{} whose runtime type is the same as the struct that -// was used to create the Unmarshaller. -func (um *Unmarshaller) Read() (interface{}, error) { - row, err := um.reader.Read() - if err != nil { - return nil, err - } - return um.unmarshalRow(row, nil) -} - -// ReadUnmatched is same as Read(), but returns a map of the columns that didn't match a field in the struct -func (um *Unmarshaller) ReadUnmatched() (interface{}, map[string]string, error) { - row, err := um.reader.Read() - if err != nil { - return nil, nil, err - } - unmatched := make(map[string]string) - value, err := um.unmarshalRow(row, unmatched) - return value, unmatched, err -} - -// validate ensures that a struct was used to create the Unmarshaller, and validates -// CSV headers against the CSV tags in the struct. -func validate(um *Unmarshaller, s interface{}, headers []string) error { - concreteType := reflect.TypeOf(s) - if concreteType.Kind() == reflect.Ptr { - concreteType = concreteType.Elem() - } - if err := ensureOutInnerType(concreteType); err != nil { - return err - } - structInfo := getStructInfo(concreteType) // Get struct info to get CSV annotations. - if len(structInfo.Fields) == 0 { - return ErrNoStructTags - } - csvHeadersLabels := make([]*fieldInfo, len(headers)) // Used to store the corresponding header <-> position in CSV - headerCount := map[string]int{} - for i, csvColumnHeader := range headers { - curHeaderCount := headerCount[csvColumnHeader] - if fieldInfo := getCSVFieldPosition(csvColumnHeader, structInfo, curHeaderCount); fieldInfo != nil { - csvHeadersLabels[i] = fieldInfo - if ShouldAlignDuplicateHeadersWithStructFieldOrder { - curHeaderCount++ - headerCount[csvColumnHeader] = curHeaderCount - } - } - } - - if FailIfDoubleHeaderNames { - if err := maybeDoubleHeaderNames(headers); err != nil { - return err - } - } - - um.Headers = headers - um.fieldInfoMap = csvHeadersLabels - um.MismatchedHeaders = mismatchHeaderFields(structInfo.Fields, headers) - um.MismatchedStructFields = mismatchStructFields(structInfo.Fields, headers) - um.out = s - return nil -} - -// unmarshalRow converts a CSV row to a struct, based on CSV struct tags. -// If unmatched is non nil, it is populated with any columns that don't map to a struct field -func (um *Unmarshaller) unmarshalRow(row []string, unmatched map[string]string) (interface{}, error) { - isPointer := false - concreteOutType := um.outType - if um.outType.Kind() == reflect.Ptr { - isPointer = true - concreteOutType = concreteOutType.Elem() - } - outValue := createNewOutInner(isPointer, concreteOutType) - for j, csvColumnContent := range row { - if j < len(um.fieldInfoMap) && um.fieldInfoMap[j] != nil { - fieldInfo := um.fieldInfoMap[j] - if err := setInnerField(&outValue, isPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct - return nil, fmt.Errorf("cannot assign field at %v to %s through index chain %v: %v", j, outValue.Type(), fieldInfo.IndexChain, err) - } - } else if unmatched != nil { - unmatched[um.Headers[j]] = csvColumnContent - } - } - return outValue.Interface(), nil -} - -// RenormalizeHeaders will remap the header names based on the headerNormalizer. -// This can be used to map a CSV to a struct where the CSV header names do not match in the file but a mapping is known -func (um *Unmarshaller) RenormalizeHeaders(headerNormalizer func([]string) []string) error { - headers := um.Headers - if headerNormalizer != nil { - headers = headerNormalizer(headers) - } - err := validate(um, um.out, headers) - if err != nil { - return err - } - - return nil -} diff --git a/vendor/github.com/pjbgf/sha1cd/cgo/sha1.c b/vendor/github.com/pjbgf/sha1cd/cgo/sha1.c deleted file mode 100644 index f532ef0e4d..0000000000 --- a/vendor/github.com/pjbgf/sha1cd/cgo/sha1.c +++ /dev/null @@ -1,2144 +0,0 @@ -/*** - * Copyright 2017 Marc Stevens , Dan Shumow (danshu@microsoft.com) - * Distributed under the MIT Software License. - * See accompanying file LICENSE.txt or copy at - * https://opensource.org/licenses/MIT - ***/ - -// Originally from: https://github.com/cr-marcstevens/sha1collisiondetection - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#include -#include -#include -#ifdef __unix__ -#include /* make sure macros like _BIG_ENDIAN visible */ -#endif -#endif - -#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C -#include SHA1DC_CUSTOM_INCLUDE_SHA1_C -#endif - -#ifndef SHA1DC_INIT_SAFE_HASH_DEFAULT -#define SHA1DC_INIT_SAFE_HASH_DEFAULT 1 -#endif - -#include "sha1.h" -#include "ubc_check.h" - -#if (defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \ - defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \ - defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || \ - defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__) || \ - defined(__386) || defined(_M_X64) || defined(_M_AMD64)) -#define SHA1DC_ON_INTEL_LIKE_PROCESSOR -#endif - -/* - Because Little-Endian architectures are most common, - we only set SHA1DC_BIGENDIAN if one of these conditions is met. - Note that all MSFT platforms are little endian, - so none of these will be defined under the MSC compiler. - If you are compiling on a big endian platform and your compiler does not define one of these, - you will have to add whatever macros your tool chain defines to indicate Big-Endianness. - */ - -#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) -/* - * Should detect Big Endian under GCC since at least 4.6.0 (gcc svn - * rev #165881). See - * https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html - * - * This also works under clang since 3.2, it copied the GCC-ism. See - * clang.git's 3b198a97d2 ("Preprocessor: add __BYTE_ORDER__ - * predefined macro", 2012-07-27) - */ -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define SHA1DC_BIGENDIAN -#endif - -/* Not under GCC-alike */ -#elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) -/* - * Should detect Big Endian under glibc.git since 14245eb70e ("entered - * into RCS", 1992-11-25). Defined in which will have been - * brought in by standard headers. See glibc.git and - * https://sourceforge.net/p/predef/wiki/Endianness/ - */ -#if __BYTE_ORDER == __BIG_ENDIAN -#define SHA1DC_BIGENDIAN -#endif - -/* Not under GCC-alike or glibc */ -#elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) -/* - * *BSD and newlib (embedded linux, cygwin, etc). - * the defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) part prevents - * this condition from matching with Solaris/sparc. - * (Solaris defines only one endian macro) - */ -#if _BYTE_ORDER == _BIG_ENDIAN -#define SHA1DC_BIGENDIAN -#endif - -/* Not under GCC-alike or glibc or *BSD or newlib */ -#elif (defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ - defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \ - defined(__sparc)) -/* - * Should define Big Endian for a whitelist of known processors. See - * https://sourceforge.net/p/predef/wiki/Endianness/ and - * http://www.oracle.com/technetwork/server-storage/solaris/portingtosolaris-138514.html - */ -#define SHA1DC_BIGENDIAN - -/* Not under GCC-alike or glibc or *BSD or newlib or */ -#elif (defined(_AIX) || defined(__hpux)) - -/* - * Defines Big Endian on a whitelist of OSs that are known to be Big - * Endian-only. See - * https://public-inbox.org/git/93056823-2740-d072-1ebd-46b440b33d7e@felt.demon.nl/ - */ -#define SHA1DC_BIGENDIAN - -/* Not under GCC-alike or glibc or *BSD or newlib or or */ -#elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR) -/* - * As a last resort before we do anything else we're not 100% sure - * about below, we blacklist specific processors here. We could add - * more, see e.g. https://wiki.debian.org/ArchitectureSpecificsMemo - */ -#else /* Not under GCC-alike or glibc or *BSD or newlib or or or */ - -/* We do nothing more here for now */ -/*#error "Uncomment this to see if you fall through all the detection"*/ - -#endif /* Big Endian detection */ - -#if (defined(SHA1DC_FORCE_LITTLEENDIAN) && defined(SHA1DC_BIGENDIAN)) -#undef SHA1DC_BIGENDIAN -#endif -#if (defined(SHA1DC_FORCE_BIGENDIAN) && !defined(SHA1DC_BIGENDIAN)) -#define SHA1DC_BIGENDIAN -#endif -/*ENDIANNESS SELECTION*/ - -#ifndef SHA1DC_FORCE_ALIGNED_ACCESS -#if defined(SHA1DC_FORCE_UNALIGNED_ACCESS) || defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR) -#define SHA1DC_ALLOW_UNALIGNED_ACCESS -#endif /*UNALIGNED ACCESS DETECTION*/ -#endif /*FORCE ALIGNED ACCESS*/ - -#define rotate_right(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) -#define rotate_left(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - -#define sha1_bswap32(x) \ - { \ - x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); \ - x = (x << 16) | (x >> 16); \ - } - -#define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1)) - -#ifdef SHA1DC_BIGENDIAN -#define sha1_load(m, t, temp) \ - { \ - temp = m[t]; \ - } -#else -#define sha1_load(m, t, temp) \ - { \ - temp = m[t]; \ - sha1_bswap32(temp); \ - } -#endif - -#define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x - -#define sha1_f1(b, c, d) ((d) ^ ((b) & ((c) ^ (d)))) -#define sha1_f2(b, c, d) ((b) ^ (c) ^ (d)) -#define sha1_f3(b, c, d) (((b) & (c)) + ((d) & ((b) ^ (c)))) -#define sha1_f4(b, c, d) ((b) ^ (c) ^ (d)) - -#define HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, m, t) \ - { \ - e += rotate_left(a, 5) + sha1_f1(b, c, d) + 0x5A827999 + m[t]; \ - b = rotate_left(b, 30); \ - } -#define HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, m, t) \ - { \ - e += rotate_left(a, 5) + sha1_f2(b, c, d) + 0x6ED9EBA1 + m[t]; \ - b = rotate_left(b, 30); \ - } -#define HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, m, t) \ - { \ - e += rotate_left(a, 5) + sha1_f3(b, c, d) + 0x8F1BBCDC + m[t]; \ - b = rotate_left(b, 30); \ - } -#define HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, m, t) \ - { \ - e += rotate_left(a, 5) + sha1_f4(b, c, d) + 0xCA62C1D6 + m[t]; \ - b = rotate_left(b, 30); \ - } - -#define HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, m, t) \ - { \ - b = rotate_right(b, 30); \ - e -= rotate_left(a, 5) + sha1_f1(b, c, d) + 0x5A827999 + m[t]; \ - } -#define HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, m, t) \ - { \ - b = rotate_right(b, 30); \ - e -= rotate_left(a, 5) + sha1_f2(b, c, d) + 0x6ED9EBA1 + m[t]; \ - } -#define HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, m, t) \ - { \ - b = rotate_right(b, 30); \ - e -= rotate_left(a, 5) + sha1_f3(b, c, d) + 0x8F1BBCDC + m[t]; \ - } -#define HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, m, t) \ - { \ - b = rotate_right(b, 30); \ - e -= rotate_left(a, 5) + sha1_f4(b, c, d) + 0xCA62C1D6 + m[t]; \ - } - -#define SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, t, temp) \ - { \ - sha1_load(m, t, temp); \ - sha1_store(W, t, temp); \ - e += temp + rotate_left(a, 5) + sha1_f1(b, c, d) + 0x5A827999; \ - b = rotate_left(b, 30); \ - } - -#define SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(a, b, c, d, e, W, t, temp) \ - { \ - temp = sha1_mix(W, t); \ - sha1_store(W, t, temp); \ - e += temp + rotate_left(a, 5) + sha1_f1(b, c, d) + 0x5A827999; \ - b = rotate_left(b, 30); \ - } - -#define SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, t, temp) \ - { \ - temp = sha1_mix(W, t); \ - sha1_store(W, t, temp); \ - e += temp + rotate_left(a, 5) + sha1_f2(b, c, d) + 0x6ED9EBA1; \ - b = rotate_left(b, 30); \ - } - -#define SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, t, temp) \ - { \ - temp = sha1_mix(W, t); \ - sha1_store(W, t, temp); \ - e += temp + rotate_left(a, 5) + sha1_f3(b, c, d) + 0x8F1BBCDC; \ - b = rotate_left(b, 30); \ - } - -#define SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, t, temp) \ - { \ - temp = sha1_mix(W, t); \ - sha1_store(W, t, temp); \ - e += temp + rotate_left(a, 5) + sha1_f4(b, c, d) + 0xCA62C1D6; \ - b = rotate_left(b, 30); \ - } - -#define SHA1_STORE_STATE(i) \ - states[i][0] = a; \ - states[i][1] = b; \ - states[i][2] = c; \ - states[i][3] = d; \ - states[i][4] = e; - -#ifdef BUILDNOCOLLDETECTSHA1COMPRESSION -void sha1_compression(uint32_t ihv[5], const uint32_t m[16]) -{ - uint32_t W[80]; - uint32_t a, b, c, d, e; - unsigned i; - - memcpy(W, m, 16 * 4); - for (i = 16; i < 80; ++i) - W[i] = sha1_mix(W, i); - - a = ihv[0]; - b = ihv[1]; - c = ihv[2]; - d = ihv[3]; - e = ihv[4]; - - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19); - - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39); - - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59); - - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79); - - ihv[0] += a; - ihv[1] += b; - ihv[2] += c; - ihv[3] += d; - ihv[4] += e; -} -#endif /*BUILDNOCOLLDETECTSHA1COMPRESSION*/ - -static void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80]) -{ - uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4]; - - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19); - - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39); - - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59); - - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79); - - ihv[0] += a; - ihv[1] += b; - ihv[2] += c; - ihv[3] += d; - ihv[4] += e; -} - -void sha1_compression_states(uint32_t ihv[5], const uint32_t m[16], uint32_t W[80], uint32_t states[80][5]) -{ - uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4]; - uint32_t temp; - -#ifdef DOSTORESTATE00 - SHA1_STORE_STATE(0) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 0, temp); - -#ifdef DOSTORESTATE01 - SHA1_STORE_STATE(1) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 1, temp); - -#ifdef DOSTORESTATE02 - SHA1_STORE_STATE(2) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 2, temp); - -#ifdef DOSTORESTATE03 - SHA1_STORE_STATE(3) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 3, temp); - -#ifdef DOSTORESTATE04 - SHA1_STORE_STATE(4) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 4, temp); - -#ifdef DOSTORESTATE05 - SHA1_STORE_STATE(5) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 5, temp); - -#ifdef DOSTORESTATE06 - SHA1_STORE_STATE(6) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 6, temp); - -#ifdef DOSTORESTATE07 - SHA1_STORE_STATE(7) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 7, temp); - -#ifdef DOSTORESTATE08 - SHA1_STORE_STATE(8) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 8, temp); - -#ifdef DOSTORESTATE09 - SHA1_STORE_STATE(9) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 9, temp); - -#ifdef DOSTORESTATE10 - SHA1_STORE_STATE(10) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 10, temp); - -#ifdef DOSTORESTATE11 - SHA1_STORE_STATE(11) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 11, temp); - -#ifdef DOSTORESTATE12 - SHA1_STORE_STATE(12) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 12, temp); - -#ifdef DOSTORESTATE13 - SHA1_STORE_STATE(13) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 13, temp); - -#ifdef DOSTORESTATE14 - SHA1_STORE_STATE(14) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 14, temp); - -#ifdef DOSTORESTATE15 - SHA1_STORE_STATE(15) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 15, temp); - -#ifdef DOSTORESTATE16 - SHA1_STORE_STATE(16) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(e, a, b, c, d, W, 16, temp); - -#ifdef DOSTORESTATE17 - SHA1_STORE_STATE(17) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(d, e, a, b, c, W, 17, temp); - -#ifdef DOSTORESTATE18 - SHA1_STORE_STATE(18) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(c, d, e, a, b, W, 18, temp); - -#ifdef DOSTORESTATE19 - SHA1_STORE_STATE(19) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(b, c, d, e, a, W, 19, temp); - -#ifdef DOSTORESTATE20 - SHA1_STORE_STATE(20) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 20, temp); - -#ifdef DOSTORESTATE21 - SHA1_STORE_STATE(21) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 21, temp); - -#ifdef DOSTORESTATE22 - SHA1_STORE_STATE(22) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 22, temp); - -#ifdef DOSTORESTATE23 - SHA1_STORE_STATE(23) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 23, temp); - -#ifdef DOSTORESTATE24 - SHA1_STORE_STATE(24) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 24, temp); - -#ifdef DOSTORESTATE25 - SHA1_STORE_STATE(25) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 25, temp); - -#ifdef DOSTORESTATE26 - SHA1_STORE_STATE(26) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 26, temp); - -#ifdef DOSTORESTATE27 - SHA1_STORE_STATE(27) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 27, temp); - -#ifdef DOSTORESTATE28 - SHA1_STORE_STATE(28) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 28, temp); - -#ifdef DOSTORESTATE29 - SHA1_STORE_STATE(29) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 29, temp); - -#ifdef DOSTORESTATE30 - SHA1_STORE_STATE(30) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 30, temp); - -#ifdef DOSTORESTATE31 - SHA1_STORE_STATE(31) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 31, temp); - -#ifdef DOSTORESTATE32 - SHA1_STORE_STATE(32) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 32, temp); - -#ifdef DOSTORESTATE33 - SHA1_STORE_STATE(33) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 33, temp); - -#ifdef DOSTORESTATE34 - SHA1_STORE_STATE(34) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 34, temp); - -#ifdef DOSTORESTATE35 - SHA1_STORE_STATE(35) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 35, temp); - -#ifdef DOSTORESTATE36 - SHA1_STORE_STATE(36) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 36, temp); - -#ifdef DOSTORESTATE37 - SHA1_STORE_STATE(37) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 37, temp); - -#ifdef DOSTORESTATE38 - SHA1_STORE_STATE(38) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 38, temp); - -#ifdef DOSTORESTATE39 - SHA1_STORE_STATE(39) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 39, temp); - -#ifdef DOSTORESTATE40 - SHA1_STORE_STATE(40) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 40, temp); - -#ifdef DOSTORESTATE41 - SHA1_STORE_STATE(41) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 41, temp); - -#ifdef DOSTORESTATE42 - SHA1_STORE_STATE(42) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 42, temp); - -#ifdef DOSTORESTATE43 - SHA1_STORE_STATE(43) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 43, temp); - -#ifdef DOSTORESTATE44 - SHA1_STORE_STATE(44) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 44, temp); - -#ifdef DOSTORESTATE45 - SHA1_STORE_STATE(45) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 45, temp); - -#ifdef DOSTORESTATE46 - SHA1_STORE_STATE(46) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 46, temp); - -#ifdef DOSTORESTATE47 - SHA1_STORE_STATE(47) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 47, temp); - -#ifdef DOSTORESTATE48 - SHA1_STORE_STATE(48) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 48, temp); - -#ifdef DOSTORESTATE49 - SHA1_STORE_STATE(49) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 49, temp); - -#ifdef DOSTORESTATE50 - SHA1_STORE_STATE(50) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 50, temp); - -#ifdef DOSTORESTATE51 - SHA1_STORE_STATE(51) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 51, temp); - -#ifdef DOSTORESTATE52 - SHA1_STORE_STATE(52) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 52, temp); - -#ifdef DOSTORESTATE53 - SHA1_STORE_STATE(53) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 53, temp); - -#ifdef DOSTORESTATE54 - SHA1_STORE_STATE(54) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 54, temp); - -#ifdef DOSTORESTATE55 - SHA1_STORE_STATE(55) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 55, temp); - -#ifdef DOSTORESTATE56 - SHA1_STORE_STATE(56) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 56, temp); - -#ifdef DOSTORESTATE57 - SHA1_STORE_STATE(57) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 57, temp); - -#ifdef DOSTORESTATE58 - SHA1_STORE_STATE(58) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 58, temp); - -#ifdef DOSTORESTATE59 - SHA1_STORE_STATE(59) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 59, temp); - -#ifdef DOSTORESTATE60 - SHA1_STORE_STATE(60) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 60, temp); - -#ifdef DOSTORESTATE61 - SHA1_STORE_STATE(61) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 61, temp); - -#ifdef DOSTORESTATE62 - SHA1_STORE_STATE(62) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 62, temp); - -#ifdef DOSTORESTATE63 - SHA1_STORE_STATE(63) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 63, temp); - -#ifdef DOSTORESTATE64 - SHA1_STORE_STATE(64) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 64, temp); - -#ifdef DOSTORESTATE65 - SHA1_STORE_STATE(65) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 65, temp); - -#ifdef DOSTORESTATE66 - SHA1_STORE_STATE(66) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 66, temp); - -#ifdef DOSTORESTATE67 - SHA1_STORE_STATE(67) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 67, temp); - -#ifdef DOSTORESTATE68 - SHA1_STORE_STATE(68) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 68, temp); - -#ifdef DOSTORESTATE69 - SHA1_STORE_STATE(69) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 69, temp); - -#ifdef DOSTORESTATE70 - SHA1_STORE_STATE(70) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 70, temp); - -#ifdef DOSTORESTATE71 - SHA1_STORE_STATE(71) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 71, temp); - -#ifdef DOSTORESTATE72 - SHA1_STORE_STATE(72) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 72, temp); - -#ifdef DOSTORESTATE73 - SHA1_STORE_STATE(73) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 73, temp); - -#ifdef DOSTORESTATE74 - SHA1_STORE_STATE(74) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 74, temp); - -#ifdef DOSTORESTATE75 - SHA1_STORE_STATE(75) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 75, temp); - -#ifdef DOSTORESTATE76 - SHA1_STORE_STATE(76) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 76, temp); - -#ifdef DOSTORESTATE77 - SHA1_STORE_STATE(77) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 77, temp); - -#ifdef DOSTORESTATE78 - SHA1_STORE_STATE(78) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 78, temp); - -#ifdef DOSTORESTATE79 - SHA1_STORE_STATE(79) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 79, temp); - - ihv[0] += a; - ihv[1] += b; - ihv[2] += c; - ihv[3] += d; - ihv[4] += e; -} - -#define SHA1_RECOMPRESS(t) \ - static void sha1recompress_fast_##t(uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) \ - { \ - uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; \ - if (t > 79) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 79); \ - if (t > 78) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 78); \ - if (t > 77) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 77); \ - if (t > 76) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 76); \ - if (t > 75) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 75); \ - if (t > 74) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 74); \ - if (t > 73) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 73); \ - if (t > 72) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 72); \ - if (t > 71) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 71); \ - if (t > 70) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 70); \ - if (t > 69) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 69); \ - if (t > 68) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 68); \ - if (t > 67) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 67); \ - if (t > 66) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 66); \ - if (t > 65) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 65); \ - if (t > 64) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 64); \ - if (t > 63) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 63); \ - if (t > 62) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 62); \ - if (t > 61) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 61); \ - if (t > 60) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 60); \ - if (t > 59) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 59); \ - if (t > 58) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 58); \ - if (t > 57) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 57); \ - if (t > 56) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 56); \ - if (t > 55) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 55); \ - if (t > 54) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 54); \ - if (t > 53) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 53); \ - if (t > 52) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 52); \ - if (t > 51) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 51); \ - if (t > 50) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 50); \ - if (t > 49) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 49); \ - if (t > 48) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 48); \ - if (t > 47) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 47); \ - if (t > 46) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 46); \ - if (t > 45) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 45); \ - if (t > 44) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 44); \ - if (t > 43) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 43); \ - if (t > 42) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 42); \ - if (t > 41) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 41); \ - if (t > 40) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 40); \ - if (t > 39) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 39); \ - if (t > 38) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 38); \ - if (t > 37) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 37); \ - if (t > 36) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 36); \ - if (t > 35) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 35); \ - if (t > 34) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 34); \ - if (t > 33) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 33); \ - if (t > 32) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 32); \ - if (t > 31) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 31); \ - if (t > 30) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 30); \ - if (t > 29) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 29); \ - if (t > 28) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 28); \ - if (t > 27) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 27); \ - if (t > 26) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 26); \ - if (t > 25) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 25); \ - if (t > 24) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 24); \ - if (t > 23) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 23); \ - if (t > 22) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 22); \ - if (t > 21) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 21); \ - if (t > 20) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 20); \ - if (t > 19) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 19); \ - if (t > 18) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 18); \ - if (t > 17) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 17); \ - if (t > 16) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 16); \ - if (t > 15) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 15); \ - if (t > 14) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 14); \ - if (t > 13) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 13); \ - if (t > 12) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 12); \ - if (t > 11) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 11); \ - if (t > 10) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 10); \ - if (t > 9) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 9); \ - if (t > 8) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 8); \ - if (t > 7) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 7); \ - if (t > 6) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 6); \ - if (t > 5) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 5); \ - if (t > 4) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 4); \ - if (t > 3) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 3); \ - if (t > 2) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 2); \ - if (t > 1) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 1); \ - if (t > 0) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 0); \ - ihvin[0] = a; \ - ihvin[1] = b; \ - ihvin[2] = c; \ - ihvin[3] = d; \ - ihvin[4] = e; \ - a = state[0]; \ - b = state[1]; \ - c = state[2]; \ - d = state[3]; \ - e = state[4]; \ - if (t <= 0) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 0); \ - if (t <= 1) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 1); \ - if (t <= 2) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 2); \ - if (t <= 3) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 3); \ - if (t <= 4) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 4); \ - if (t <= 5) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 5); \ - if (t <= 6) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 6); \ - if (t <= 7) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 7); \ - if (t <= 8) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 8); \ - if (t <= 9) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 9); \ - if (t <= 10) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 10); \ - if (t <= 11) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 11); \ - if (t <= 12) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 12); \ - if (t <= 13) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 13); \ - if (t <= 14) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 14); \ - if (t <= 15) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 15); \ - if (t <= 16) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 16); \ - if (t <= 17) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 17); \ - if (t <= 18) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 18); \ - if (t <= 19) \ - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 19); \ - if (t <= 20) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 20); \ - if (t <= 21) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 21); \ - if (t <= 22) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 22); \ - if (t <= 23) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 23); \ - if (t <= 24) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 24); \ - if (t <= 25) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 25); \ - if (t <= 26) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 26); \ - if (t <= 27) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 27); \ - if (t <= 28) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 28); \ - if (t <= 29) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 29); \ - if (t <= 30) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 30); \ - if (t <= 31) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 31); \ - if (t <= 32) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 32); \ - if (t <= 33) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 33); \ - if (t <= 34) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 34); \ - if (t <= 35) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 35); \ - if (t <= 36) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 36); \ - if (t <= 37) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 37); \ - if (t <= 38) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 38); \ - if (t <= 39) \ - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 39); \ - if (t <= 40) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 40); \ - if (t <= 41) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 41); \ - if (t <= 42) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 42); \ - if (t <= 43) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 43); \ - if (t <= 44) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 44); \ - if (t <= 45) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 45); \ - if (t <= 46) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 46); \ - if (t <= 47) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 47); \ - if (t <= 48) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 48); \ - if (t <= 49) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 49); \ - if (t <= 50) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 50); \ - if (t <= 51) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 51); \ - if (t <= 52) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 52); \ - if (t <= 53) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 53); \ - if (t <= 54) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 54); \ - if (t <= 55) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 55); \ - if (t <= 56) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 56); \ - if (t <= 57) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 57); \ - if (t <= 58) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 58); \ - if (t <= 59) \ - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 59); \ - if (t <= 60) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 60); \ - if (t <= 61) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 61); \ - if (t <= 62) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 62); \ - if (t <= 63) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 63); \ - if (t <= 64) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 64); \ - if (t <= 65) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 65); \ - if (t <= 66) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 66); \ - if (t <= 67) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 67); \ - if (t <= 68) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 68); \ - if (t <= 69) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 69); \ - if (t <= 70) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 70); \ - if (t <= 71) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 71); \ - if (t <= 72) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 72); \ - if (t <= 73) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 73); \ - if (t <= 74) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 74); \ - if (t <= 75) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 75); \ - if (t <= 76) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 76); \ - if (t <= 77) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 77); \ - if (t <= 78) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 78); \ - if (t <= 79) \ - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 79); \ - ihvout[0] = ihvin[0] + a; \ - ihvout[1] = ihvin[1] + b; \ - ihvout[2] = ihvin[2] + c; \ - ihvout[3] = ihvin[3] + d; \ - ihvout[4] = ihvin[4] + e; \ - } - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4127) /* Compiler complains about the checks in the above macro being constant. */ -#endif - -#ifdef DOSTORESTATE0 -SHA1_RECOMPRESS(0) -#endif - -#ifdef DOSTORESTATE1 -SHA1_RECOMPRESS(1) -#endif - -#ifdef DOSTORESTATE2 -SHA1_RECOMPRESS(2) -#endif - -#ifdef DOSTORESTATE3 -SHA1_RECOMPRESS(3) -#endif - -#ifdef DOSTORESTATE4 -SHA1_RECOMPRESS(4) -#endif - -#ifdef DOSTORESTATE5 -SHA1_RECOMPRESS(5) -#endif - -#ifdef DOSTORESTATE6 -SHA1_RECOMPRESS(6) -#endif - -#ifdef DOSTORESTATE7 -SHA1_RECOMPRESS(7) -#endif - -#ifdef DOSTORESTATE8 -SHA1_RECOMPRESS(8) -#endif - -#ifdef DOSTORESTATE9 -SHA1_RECOMPRESS(9) -#endif - -#ifdef DOSTORESTATE10 -SHA1_RECOMPRESS(10) -#endif - -#ifdef DOSTORESTATE11 -SHA1_RECOMPRESS(11) -#endif - -#ifdef DOSTORESTATE12 -SHA1_RECOMPRESS(12) -#endif - -#ifdef DOSTORESTATE13 -SHA1_RECOMPRESS(13) -#endif - -#ifdef DOSTORESTATE14 -SHA1_RECOMPRESS(14) -#endif - -#ifdef DOSTORESTATE15 -SHA1_RECOMPRESS(15) -#endif - -#ifdef DOSTORESTATE16 -SHA1_RECOMPRESS(16) -#endif - -#ifdef DOSTORESTATE17 -SHA1_RECOMPRESS(17) -#endif - -#ifdef DOSTORESTATE18 -SHA1_RECOMPRESS(18) -#endif - -#ifdef DOSTORESTATE19 -SHA1_RECOMPRESS(19) -#endif - -#ifdef DOSTORESTATE20 -SHA1_RECOMPRESS(20) -#endif - -#ifdef DOSTORESTATE21 -SHA1_RECOMPRESS(21) -#endif - -#ifdef DOSTORESTATE22 -SHA1_RECOMPRESS(22) -#endif - -#ifdef DOSTORESTATE23 -SHA1_RECOMPRESS(23) -#endif - -#ifdef DOSTORESTATE24 -SHA1_RECOMPRESS(24) -#endif - -#ifdef DOSTORESTATE25 -SHA1_RECOMPRESS(25) -#endif - -#ifdef DOSTORESTATE26 -SHA1_RECOMPRESS(26) -#endif - -#ifdef DOSTORESTATE27 -SHA1_RECOMPRESS(27) -#endif - -#ifdef DOSTORESTATE28 -SHA1_RECOMPRESS(28) -#endif - -#ifdef DOSTORESTATE29 -SHA1_RECOMPRESS(29) -#endif - -#ifdef DOSTORESTATE30 -SHA1_RECOMPRESS(30) -#endif - -#ifdef DOSTORESTATE31 -SHA1_RECOMPRESS(31) -#endif - -#ifdef DOSTORESTATE32 -SHA1_RECOMPRESS(32) -#endif - -#ifdef DOSTORESTATE33 -SHA1_RECOMPRESS(33) -#endif - -#ifdef DOSTORESTATE34 -SHA1_RECOMPRESS(34) -#endif - -#ifdef DOSTORESTATE35 -SHA1_RECOMPRESS(35) -#endif - -#ifdef DOSTORESTATE36 -SHA1_RECOMPRESS(36) -#endif - -#ifdef DOSTORESTATE37 -SHA1_RECOMPRESS(37) -#endif - -#ifdef DOSTORESTATE38 -SHA1_RECOMPRESS(38) -#endif - -#ifdef DOSTORESTATE39 -SHA1_RECOMPRESS(39) -#endif - -#ifdef DOSTORESTATE40 -SHA1_RECOMPRESS(40) -#endif - -#ifdef DOSTORESTATE41 -SHA1_RECOMPRESS(41) -#endif - -#ifdef DOSTORESTATE42 -SHA1_RECOMPRESS(42) -#endif - -#ifdef DOSTORESTATE43 -SHA1_RECOMPRESS(43) -#endif - -#ifdef DOSTORESTATE44 -SHA1_RECOMPRESS(44) -#endif - -#ifdef DOSTORESTATE45 -SHA1_RECOMPRESS(45) -#endif - -#ifdef DOSTORESTATE46 -SHA1_RECOMPRESS(46) -#endif - -#ifdef DOSTORESTATE47 -SHA1_RECOMPRESS(47) -#endif - -#ifdef DOSTORESTATE48 -SHA1_RECOMPRESS(48) -#endif - -#ifdef DOSTORESTATE49 -SHA1_RECOMPRESS(49) -#endif - -#ifdef DOSTORESTATE50 -SHA1_RECOMPRESS(50) -#endif - -#ifdef DOSTORESTATE51 -SHA1_RECOMPRESS(51) -#endif - -#ifdef DOSTORESTATE52 -SHA1_RECOMPRESS(52) -#endif - -#ifdef DOSTORESTATE53 -SHA1_RECOMPRESS(53) -#endif - -#ifdef DOSTORESTATE54 -SHA1_RECOMPRESS(54) -#endif - -#ifdef DOSTORESTATE55 -SHA1_RECOMPRESS(55) -#endif - -#ifdef DOSTORESTATE56 -SHA1_RECOMPRESS(56) -#endif - -#ifdef DOSTORESTATE57 -SHA1_RECOMPRESS(57) -#endif - -#ifdef DOSTORESTATE58 -SHA1_RECOMPRESS(58) -#endif - -#ifdef DOSTORESTATE59 -SHA1_RECOMPRESS(59) -#endif - -#ifdef DOSTORESTATE60 -SHA1_RECOMPRESS(60) -#endif - -#ifdef DOSTORESTATE61 -SHA1_RECOMPRESS(61) -#endif - -#ifdef DOSTORESTATE62 -SHA1_RECOMPRESS(62) -#endif - -#ifdef DOSTORESTATE63 -SHA1_RECOMPRESS(63) -#endif - -#ifdef DOSTORESTATE64 -SHA1_RECOMPRESS(64) -#endif - -#ifdef DOSTORESTATE65 -SHA1_RECOMPRESS(65) -#endif - -#ifdef DOSTORESTATE66 -SHA1_RECOMPRESS(66) -#endif - -#ifdef DOSTORESTATE67 -SHA1_RECOMPRESS(67) -#endif - -#ifdef DOSTORESTATE68 -SHA1_RECOMPRESS(68) -#endif - -#ifdef DOSTORESTATE69 -SHA1_RECOMPRESS(69) -#endif - -#ifdef DOSTORESTATE70 -SHA1_RECOMPRESS(70) -#endif - -#ifdef DOSTORESTATE71 -SHA1_RECOMPRESS(71) -#endif - -#ifdef DOSTORESTATE72 -SHA1_RECOMPRESS(72) -#endif - -#ifdef DOSTORESTATE73 -SHA1_RECOMPRESS(73) -#endif - -#ifdef DOSTORESTATE74 -SHA1_RECOMPRESS(74) -#endif - -#ifdef DOSTORESTATE75 -SHA1_RECOMPRESS(75) -#endif - -#ifdef DOSTORESTATE76 -SHA1_RECOMPRESS(76) -#endif - -#ifdef DOSTORESTATE77 -SHA1_RECOMPRESS(77) -#endif - -#ifdef DOSTORESTATE78 -SHA1_RECOMPRESS(78) -#endif - -#ifdef DOSTORESTATE79 -SHA1_RECOMPRESS(79) -#endif - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -static void sha1_recompression_step(uint32_t step, uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) -{ - switch (step) - { -#ifdef DOSTORESTATE0 - case 0: - sha1recompress_fast_0(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE1 - case 1: - sha1recompress_fast_1(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE2 - case 2: - sha1recompress_fast_2(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE3 - case 3: - sha1recompress_fast_3(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE4 - case 4: - sha1recompress_fast_4(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE5 - case 5: - sha1recompress_fast_5(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE6 - case 6: - sha1recompress_fast_6(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE7 - case 7: - sha1recompress_fast_7(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE8 - case 8: - sha1recompress_fast_8(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE9 - case 9: - sha1recompress_fast_9(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE10 - case 10: - sha1recompress_fast_10(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE11 - case 11: - sha1recompress_fast_11(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE12 - case 12: - sha1recompress_fast_12(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE13 - case 13: - sha1recompress_fast_13(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE14 - case 14: - sha1recompress_fast_14(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE15 - case 15: - sha1recompress_fast_15(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE16 - case 16: - sha1recompress_fast_16(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE17 - case 17: - sha1recompress_fast_17(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE18 - case 18: - sha1recompress_fast_18(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE19 - case 19: - sha1recompress_fast_19(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE20 - case 20: - sha1recompress_fast_20(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE21 - case 21: - sha1recompress_fast_21(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE22 - case 22: - sha1recompress_fast_22(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE23 - case 23: - sha1recompress_fast_23(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE24 - case 24: - sha1recompress_fast_24(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE25 - case 25: - sha1recompress_fast_25(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE26 - case 26: - sha1recompress_fast_26(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE27 - case 27: - sha1recompress_fast_27(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE28 - case 28: - sha1recompress_fast_28(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE29 - case 29: - sha1recompress_fast_29(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE30 - case 30: - sha1recompress_fast_30(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE31 - case 31: - sha1recompress_fast_31(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE32 - case 32: - sha1recompress_fast_32(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE33 - case 33: - sha1recompress_fast_33(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE34 - case 34: - sha1recompress_fast_34(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE35 - case 35: - sha1recompress_fast_35(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE36 - case 36: - sha1recompress_fast_36(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE37 - case 37: - sha1recompress_fast_37(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE38 - case 38: - sha1recompress_fast_38(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE39 - case 39: - sha1recompress_fast_39(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE40 - case 40: - sha1recompress_fast_40(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE41 - case 41: - sha1recompress_fast_41(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE42 - case 42: - sha1recompress_fast_42(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE43 - case 43: - sha1recompress_fast_43(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE44 - case 44: - sha1recompress_fast_44(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE45 - case 45: - sha1recompress_fast_45(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE46 - case 46: - sha1recompress_fast_46(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE47 - case 47: - sha1recompress_fast_47(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE48 - case 48: - sha1recompress_fast_48(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE49 - case 49: - sha1recompress_fast_49(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE50 - case 50: - sha1recompress_fast_50(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE51 - case 51: - sha1recompress_fast_51(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE52 - case 52: - sha1recompress_fast_52(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE53 - case 53: - sha1recompress_fast_53(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE54 - case 54: - sha1recompress_fast_54(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE55 - case 55: - sha1recompress_fast_55(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE56 - case 56: - sha1recompress_fast_56(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE57 - case 57: - sha1recompress_fast_57(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE58 - case 58: - sha1recompress_fast_58(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE59 - case 59: - sha1recompress_fast_59(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE60 - case 60: - sha1recompress_fast_60(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE61 - case 61: - sha1recompress_fast_61(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE62 - case 62: - sha1recompress_fast_62(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE63 - case 63: - sha1recompress_fast_63(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE64 - case 64: - sha1recompress_fast_64(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE65 - case 65: - sha1recompress_fast_65(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE66 - case 66: - sha1recompress_fast_66(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE67 - case 67: - sha1recompress_fast_67(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE68 - case 68: - sha1recompress_fast_68(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE69 - case 69: - sha1recompress_fast_69(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE70 - case 70: - sha1recompress_fast_70(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE71 - case 71: - sha1recompress_fast_71(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE72 - case 72: - sha1recompress_fast_72(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE73 - case 73: - sha1recompress_fast_73(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE74 - case 74: - sha1recompress_fast_74(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE75 - case 75: - sha1recompress_fast_75(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE76 - case 76: - sha1recompress_fast_76(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE77 - case 77: - sha1recompress_fast_77(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE78 - case 78: - sha1recompress_fast_78(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE79 - case 79: - sha1recompress_fast_79(ihvin, ihvout, me2, state); - break; -#endif - default: - abort(); - } -} - -static void sha1_process(SHA1_CTX *ctx, const uint32_t block[16]) -{ - unsigned i, j; - uint32_t ubc_dv_mask[DVMASKSIZE] = {0xFFFFFFFF}; - uint32_t ihvtmp[5]; - - ctx->ihv1[0] = ctx->ihv[0]; - ctx->ihv1[1] = ctx->ihv[1]; - ctx->ihv1[2] = ctx->ihv[2]; - ctx->ihv1[3] = ctx->ihv[3]; - ctx->ihv1[4] = ctx->ihv[4]; - - sha1_compression_states(ctx->ihv, block, ctx->m1, ctx->states); - - if (ctx->detect_coll) - { - if (ctx->ubc_check) - { - ubc_check(ctx->m1, ubc_dv_mask); - } - - if (ubc_dv_mask[0] != 0) - { - for (i = 0; sha1_dvs[i].dvType != 0; ++i) - { - if (ubc_dv_mask[0] & ((uint32_t)(1) << sha1_dvs[i].maskb)) - { - for (j = 0; j < 80; ++j) - ctx->m2[j] = ctx->m1[j] ^ sha1_dvs[i].dm[j]; - - sha1_recompression_step(sha1_dvs[i].testt, ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]); - - /* to verify SHA-1 collision detection code with collisions for reduced-step SHA-1 */ - if ((0 == ((ihvtmp[0] ^ ctx->ihv[0]) | (ihvtmp[1] ^ ctx->ihv[1]) | (ihvtmp[2] ^ ctx->ihv[2]) | (ihvtmp[3] ^ ctx->ihv[3]) | (ihvtmp[4] ^ ctx->ihv[4]))) || - (ctx->reduced_round_coll && 0 == ((ctx->ihv1[0] ^ ctx->ihv2[0]) | (ctx->ihv1[1] ^ ctx->ihv2[1]) | (ctx->ihv1[2] ^ ctx->ihv2[2]) | (ctx->ihv1[3] ^ ctx->ihv2[3]) | (ctx->ihv1[4] ^ ctx->ihv2[4])))) - { - ctx->found_collision = 1; - - if (ctx->safe_hash) - { - sha1_compression_W(ctx->ihv, ctx->m1); - sha1_compression_W(ctx->ihv, ctx->m1); - } - - break; - } - } - } - } - } -} - -void SHA1DCInit(SHA1_CTX *ctx) -{ - ctx->total = 0; - ctx->ihv[0] = 0x67452301; - ctx->ihv[1] = 0xEFCDAB89; - ctx->ihv[2] = 0x98BADCFE; - ctx->ihv[3] = 0x10325476; - ctx->ihv[4] = 0xC3D2E1F0; - ctx->found_collision = 0; - ctx->safe_hash = SHA1DC_INIT_SAFE_HASH_DEFAULT; - ctx->ubc_check = 1; - ctx->detect_coll = 1; - ctx->reduced_round_coll = 0; - ctx->callback = NULL; -} - -void SHA1DCSetSafeHash(SHA1_CTX *ctx, int safehash) -{ - if (safehash) - ctx->safe_hash = 1; - else - ctx->safe_hash = 0; -} - -void SHA1DCSetUseUBC(SHA1_CTX *ctx, int ubc_check) -{ - if (ubc_check) - ctx->ubc_check = 1; - else - ctx->ubc_check = 0; -} - -void SHA1DCSetUseDetectColl(SHA1_CTX *ctx, int detect_coll) -{ - if (detect_coll) - ctx->detect_coll = 1; - else - ctx->detect_coll = 0; -} - -void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX *ctx, int reduced_round_coll) -{ - if (reduced_round_coll) - ctx->reduced_round_coll = 1; - else - ctx->reduced_round_coll = 0; -} - -void SHA1DCSetCallback(SHA1_CTX *ctx, collision_block_callback callback) -{ - ctx->callback = callback; -} - -void SHA1DCUpdate(SHA1_CTX *ctx, const char *buf, size_t len) -{ - unsigned left, fill; - - if (len == 0) - return; - - left = ctx->total & 63; - fill = 64 - left; - - if (left && len >= fill) - { - ctx->total += fill; - memcpy(ctx->buffer + left, buf, fill); - sha1_process(ctx, (uint32_t *)(ctx->buffer)); - buf += fill; - len -= fill; - left = 0; - } - while (len >= 64) - { - ctx->total += 64; - -#if defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) - sha1_process(ctx, (uint32_t *)(buf)); -#else - memcpy(ctx->buffer, buf, 64); - sha1_process(ctx, (uint32_t *)(ctx->buffer)); -#endif /* defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) */ - buf += 64; - len -= 64; - } - if (len > 0) - { - ctx->total += len; - memcpy(ctx->buffer + left, buf, len); - } -} - -static const unsigned char sha1_padding[64] = - { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - -int SHA1DCFinal(unsigned char output[20], SHA1_CTX *ctx) -{ - uint32_t last = ctx->total & 63; - uint32_t padn = (last < 56) ? (56 - last) : (120 - last); - uint64_t total; - SHA1DCUpdate(ctx, (const char *)(sha1_padding), padn); - - total = ctx->total - padn; - total <<= 3; - ctx->buffer[56] = (unsigned char)(total >> 56); - ctx->buffer[57] = (unsigned char)(total >> 48); - ctx->buffer[58] = (unsigned char)(total >> 40); - ctx->buffer[59] = (unsigned char)(total >> 32); - ctx->buffer[60] = (unsigned char)(total >> 24); - ctx->buffer[61] = (unsigned char)(total >> 16); - ctx->buffer[62] = (unsigned char)(total >> 8); - ctx->buffer[63] = (unsigned char)(total); - sha1_process(ctx, (uint32_t *)(ctx->buffer)); - output[0] = (unsigned char)(ctx->ihv[0] >> 24); - output[1] = (unsigned char)(ctx->ihv[0] >> 16); - output[2] = (unsigned char)(ctx->ihv[0] >> 8); - output[3] = (unsigned char)(ctx->ihv[0]); - output[4] = (unsigned char)(ctx->ihv[1] >> 24); - output[5] = (unsigned char)(ctx->ihv[1] >> 16); - output[6] = (unsigned char)(ctx->ihv[1] >> 8); - output[7] = (unsigned char)(ctx->ihv[1]); - output[8] = (unsigned char)(ctx->ihv[2] >> 24); - output[9] = (unsigned char)(ctx->ihv[2] >> 16); - output[10] = (unsigned char)(ctx->ihv[2] >> 8); - output[11] = (unsigned char)(ctx->ihv[2]); - output[12] = (unsigned char)(ctx->ihv[3] >> 24); - output[13] = (unsigned char)(ctx->ihv[3] >> 16); - output[14] = (unsigned char)(ctx->ihv[3] >> 8); - output[15] = (unsigned char)(ctx->ihv[3]); - output[16] = (unsigned char)(ctx->ihv[4] >> 24); - output[17] = (unsigned char)(ctx->ihv[4] >> 16); - output[18] = (unsigned char)(ctx->ihv[4] >> 8); - output[19] = (unsigned char)(ctx->ihv[4]); - return ctx->found_collision; -} - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C -#endif diff --git a/vendor/github.com/pjbgf/sha1cd/cgo/sha1.h b/vendor/github.com/pjbgf/sha1cd/cgo/sha1.h deleted file mode 100644 index ce4942f617..0000000000 --- a/vendor/github.com/pjbgf/sha1cd/cgo/sha1.h +++ /dev/null @@ -1,114 +0,0 @@ -/*** - * Copyright 2017 Marc Stevens , Dan Shumow - * Distributed under the MIT Software License. - * See accompanying file LICENSE.txt or copy at - * https://opensource.org/licenses/MIT - ***/ - -// Originally from: https://github.com/cr-marcstevens/sha1collisiondetection - -#ifndef SHA1DC_SHA1_H -#define SHA1DC_SHA1_H - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#endif - - /* sha-1 compression function that takes an already expanded message, and additionally store intermediate states */ - /* only stores states ii (the state between step ii-1 and step ii) when DOSTORESTATEii is defined in ubc_check.h */ - void sha1_compression_states(uint32_t[5], const uint32_t[16], uint32_t[80], uint32_t[80][5]); - - /* - // Function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]). - // Where 0 <= T < 80 - // me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference.) - // state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block. - // The function will return: - // ihvin: The reconstructed input chaining value. - // ihvout: The reconstructed output chaining value. - */ - typedef void (*sha1_recompression_type)(uint32_t *, uint32_t *, const uint32_t *, const uint32_t *); - - /* A callback function type that can be set to be called when a collision block has been found: */ - /* void collision_block_callback(uint64_t byteoffset, const uint32_t ihvin1[5], const uint32_t ihvin2[5], const uint32_t m1[80], const uint32_t m2[80]) */ - typedef void (*collision_block_callback)(uint64_t, const uint32_t *, const uint32_t *, const uint32_t *, const uint32_t *); - - /* The SHA-1 context. */ - typedef struct - { - uint64_t total; - uint32_t ihv[5]; - unsigned char buffer[64]; - int found_collision; - int safe_hash; - int detect_coll; - int ubc_check; - int reduced_round_coll; - collision_block_callback callback; - - uint32_t ihv1[5]; - uint32_t ihv2[5]; - uint32_t m1[80]; - uint32_t m2[80]; - uint32_t states[80][5]; - } SHA1_CTX; - - /* Initialize SHA-1 context. */ - void SHA1DCInit(SHA1_CTX *); - - /* - Function to enable safe SHA-1 hashing: - Collision attacks are thwarted by hashing a detected near-collision block 3 times. - Think of it as extending SHA-1 from 80-steps to 240-steps for such blocks: - The best collision attacks against SHA-1 have complexity about 2^60, - thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180. - An attacker would be better off using a generic birthday search of complexity 2^80. - - Enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected, - but it will result in a different SHA-1 hash for messages where a collision attack was detected. - This will automatically invalidate SHA-1 based digital signature forgeries. - Enabled by default. - */ - void SHA1DCSetSafeHash(SHA1_CTX *, int); - - /* - Function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up). - Enabled by default - */ - void SHA1DCSetUseUBC(SHA1_CTX *, int); - - /* - Function to disable or enable the use of Collision Detection. - Enabled by default. - */ - void SHA1DCSetUseDetectColl(SHA1_CTX *, int); - - /* function to disable or enable the detection of reduced-round SHA-1 collisions */ - /* disabled by default */ - void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX *, int); - - /* function to set a callback function, pass NULL to disable */ - /* by default no callback set */ - void SHA1DCSetCallback(SHA1_CTX *, collision_block_callback); - - /* update SHA-1 context with buffer contents */ - void SHA1DCUpdate(SHA1_CTX *, const char *, size_t); - - /* obtain SHA-1 hash from SHA-1 context */ - /* returns: 0 = no collision detected, otherwise = collision found => warn user for active attack */ - int SHA1DCFinal(unsigned char[20], SHA1_CTX *); - -#if defined(__cplusplus) -} -#endif - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H -#endif - -#endif diff --git a/vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.c b/vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.c deleted file mode 100644 index b3d58ce282..0000000000 --- a/vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.c +++ /dev/null @@ -1,297 +0,0 @@ -/*** - * Copyright 2017 Marc Stevens , Dan Shumow - * Distributed under the MIT Software License. - * See accompanying file LICENSE.txt or copy at - * https://opensource.org/licenses/MIT - ***/ - -// Originally from: https://github.com/cr-marcstevens/sha1collisiondetection - -/* -// this file was generated by the 'parse_bitrel' program in the tools section -// using the data files from directory 'tools/data/3565' -// -// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check -// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper) -// dm[80] is the expanded message block XOR-difference defined by the DV -// testt is the step to do the recompression from for collision detection -// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check -// -// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs -// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met -// thus one needs to do the recompression check for each DV that has its bit set -// -// ubc_check is programmatically generated and the unavoidable bitconditions have been hardcoded -// a directly verifiable version named ubc_check_verify can be found in ubc_check_verify.c -// ubc_check has been verified against ubc_check_verify using the 'ubc_check_test' program in the tools section -*/ - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#endif -#ifdef SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C -#include SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C -#endif -#include "ubc_check.h" - -static const uint32_t DV_I_43_0_bit = (uint32_t)(1) << 0; -static const uint32_t DV_I_44_0_bit = (uint32_t)(1) << 1; -static const uint32_t DV_I_45_0_bit = (uint32_t)(1) << 2; -static const uint32_t DV_I_46_0_bit = (uint32_t)(1) << 3; -static const uint32_t DV_I_46_2_bit = (uint32_t)(1) << 4; -static const uint32_t DV_I_47_0_bit = (uint32_t)(1) << 5; -static const uint32_t DV_I_47_2_bit = (uint32_t)(1) << 6; -static const uint32_t DV_I_48_0_bit = (uint32_t)(1) << 7; -static const uint32_t DV_I_48_2_bit = (uint32_t)(1) << 8; -static const uint32_t DV_I_49_0_bit = (uint32_t)(1) << 9; -static const uint32_t DV_I_49_2_bit = (uint32_t)(1) << 10; -static const uint32_t DV_I_50_0_bit = (uint32_t)(1) << 11; -static const uint32_t DV_I_50_2_bit = (uint32_t)(1) << 12; -static const uint32_t DV_I_51_0_bit = (uint32_t)(1) << 13; -static const uint32_t DV_I_51_2_bit = (uint32_t)(1) << 14; -static const uint32_t DV_I_52_0_bit = (uint32_t)(1) << 15; -static const uint32_t DV_II_45_0_bit = (uint32_t)(1) << 16; -static const uint32_t DV_II_46_0_bit = (uint32_t)(1) << 17; -static const uint32_t DV_II_46_2_bit = (uint32_t)(1) << 18; -static const uint32_t DV_II_47_0_bit = (uint32_t)(1) << 19; -static const uint32_t DV_II_48_0_bit = (uint32_t)(1) << 20; -static const uint32_t DV_II_49_0_bit = (uint32_t)(1) << 21; -static const uint32_t DV_II_49_2_bit = (uint32_t)(1) << 22; -static const uint32_t DV_II_50_0_bit = (uint32_t)(1) << 23; -static const uint32_t DV_II_50_2_bit = (uint32_t)(1) << 24; -static const uint32_t DV_II_51_0_bit = (uint32_t)(1) << 25; -static const uint32_t DV_II_51_2_bit = (uint32_t)(1) << 26; -static const uint32_t DV_II_52_0_bit = (uint32_t)(1) << 27; -static const uint32_t DV_II_53_0_bit = (uint32_t)(1) << 28; -static const uint32_t DV_II_54_0_bit = (uint32_t)(1) << 29; -static const uint32_t DV_II_55_0_bit = (uint32_t)(1) << 30; -static const uint32_t DV_II_56_0_bit = (uint32_t)(1) << 31; - -dv_info_t sha1_dvs[] = - { - {1, 43, 0, 58, 0, 0, {0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164, 0x00000408, 0x800000e6, 0x8000004c, 0x00000803, 0x80000161, 0x80000599}}, {1, 44, 0, 58, 0, 1, {0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164, 0x00000408, 0x800000e6, 0x8000004c, 0x00000803, 0x80000161}}, {1, 45, 0, 58, 0, 2, {0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164, 0x00000408, 0x800000e6, 0x8000004c, 0x00000803}}, {1, 46, 0, 58, 0, 3, {0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164, 0x00000408, 0x800000e6, 0x8000004c}}, {1, 46, 2, 58, 0, 4, {0xb0000040, 0xd0000053, 0xd0000022, 0x20000000, 0x60000032, 0x60000043, 0x20000040, 0xe0000042, 0x60000002, 0x80000001, 0x00000020, 0x00000003, 0x40000052, 0x40000040, 0xe0000052, 0xa0000000, 0x80000040, 0x20000001, 0x20000060, 0x80000001, 0x40000042, 0xc0000043, 0x40000022, 0x00000003, 0x40000042, 0xc0000043, 0xc0000022, 0x00000001, 0x40000002, 0xc0000043, 0x40000062, 0x80000001, 0x40000042, 0x40000042, 0x40000002, 0x00000002, 0x00000040, 0x80000002, 0x80000000, 0x80000002, 0x80000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000000, 0x00000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000101, 0x00000009, 0x00000012, 0x00000202, 0x0000001a, 0x00000124, 0x0000040c, 0x00000026, 0x0000004a, 0x0000080a, 0x00000060, 0x00000590, 0x00001020, 0x0000039a, 0x00000132}}, {1, 47, 0, 58, 0, 5, {0xc8000010, 0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164, 0x00000408, 0x800000e6}}, {1, 47, 2, 58, 0, 6, {0x20000043, 0xb0000040, 0xd0000053, 0xd0000022, 0x20000000, 0x60000032, 0x60000043, 0x20000040, 0xe0000042, 0x60000002, 0x80000001, 0x00000020, 0x00000003, 0x40000052, 0x40000040, 0xe0000052, 0xa0000000, 0x80000040, 0x20000001, 0x20000060, 0x80000001, 0x40000042, 0xc0000043, 0x40000022, 0x00000003, 0x40000042, 0xc0000043, 0xc0000022, 0x00000001, 0x40000002, 0xc0000043, 0x40000062, 0x80000001, 0x40000042, 0x40000042, 0x40000002, 0x00000002, 0x00000040, 0x80000002, 0x80000000, 0x80000002, 0x80000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000000, 0x00000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000101, 0x00000009, 0x00000012, 0x00000202, 0x0000001a, 0x00000124, 0x0000040c, 0x00000026, 0x0000004a, 0x0000080a, 0x00000060, 0x00000590, 0x00001020, 0x0000039a}}, {1, 48, 0, 58, 0, 7, {0xb800000a, 0xc8000010, 0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164, 0x00000408}}, {1, 48, 2, 58, 0, 8, {0xe000002a, 0x20000043, 0xb0000040, 0xd0000053, 0xd0000022, 0x20000000, 0x60000032, 0x60000043, 0x20000040, 0xe0000042, 0x60000002, 0x80000001, 0x00000020, 0x00000003, 0x40000052, 0x40000040, 0xe0000052, 0xa0000000, 0x80000040, 0x20000001, 0x20000060, 0x80000001, 0x40000042, 0xc0000043, 0x40000022, 0x00000003, 0x40000042, 0xc0000043, 0xc0000022, 0x00000001, 0x40000002, 0xc0000043, 0x40000062, 0x80000001, 0x40000042, 0x40000042, 0x40000002, 0x00000002, 0x00000040, 0x80000002, 0x80000000, 0x80000002, 0x80000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000000, 0x00000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000101, 0x00000009, 0x00000012, 0x00000202, 0x0000001a, 0x00000124, 0x0000040c, 0x00000026, 0x0000004a, 0x0000080a, 0x00000060, 0x00000590, 0x00001020}}, {1, 49, 0, 58, 0, 9, {0x18000000, 0xb800000a, 0xc8000010, 0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018, 0x00000164}}, {1, 49, 2, 58, 0, 10, {0x60000000, 0xe000002a, 0x20000043, 0xb0000040, 0xd0000053, 0xd0000022, 0x20000000, 0x60000032, 0x60000043, 0x20000040, 0xe0000042, 0x60000002, 0x80000001, 0x00000020, 0x00000003, 0x40000052, 0x40000040, 0xe0000052, 0xa0000000, 0x80000040, 0x20000001, 0x20000060, 0x80000001, 0x40000042, 0xc0000043, 0x40000022, 0x00000003, 0x40000042, 0xc0000043, 0xc0000022, 0x00000001, 0x40000002, 0xc0000043, 0x40000062, 0x80000001, 0x40000042, 0x40000042, 0x40000002, 0x00000002, 0x00000040, 0x80000002, 0x80000000, 0x80000002, 0x80000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000000, 0x00000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000101, 0x00000009, 0x00000012, 0x00000202, 0x0000001a, 0x00000124, 0x0000040c, 0x00000026, 0x0000004a, 0x0000080a, 0x00000060, 0x00000590}}, {1, 50, 0, 65, 0, 11, {0x0800000c, 0x18000000, 0xb800000a, 0xc8000010, 0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202, 0x00000018}}, {1, 50, 2, 65, 0, 12, {0x20000030, 0x60000000, 0xe000002a, 0x20000043, 0xb0000040, 0xd0000053, 0xd0000022, 0x20000000, 0x60000032, 0x60000043, 0x20000040, 0xe0000042, 0x60000002, 0x80000001, 0x00000020, 0x00000003, 0x40000052, 0x40000040, 0xe0000052, 0xa0000000, 0x80000040, 0x20000001, 0x20000060, 0x80000001, 0x40000042, 0xc0000043, 0x40000022, 0x00000003, 0x40000042, 0xc0000043, 0xc0000022, 0x00000001, 0x40000002, 0xc0000043, 0x40000062, 0x80000001, 0x40000042, 0x40000042, 0x40000002, 0x00000002, 0x00000040, 0x80000002, 0x80000000, 0x80000002, 0x80000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000000, 0x00000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000101, 0x00000009, 0x00000012, 0x00000202, 0x0000001a, 0x00000124, 0x0000040c, 0x00000026, 0x0000004a, 0x0000080a, 0x00000060}}, {1, 51, 0, 65, 0, 13, {0xe8000000, 0x0800000c, 0x18000000, 0xb800000a, 0xc8000010, 0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012, 0x80000202}}, {1, 51, 2, 65, 0, 14, {0xa0000003, 0x20000030, 0x60000000, 0xe000002a, 0x20000043, 0xb0000040, 0xd0000053, 0xd0000022, 0x20000000, 0x60000032, 0x60000043, 0x20000040, 0xe0000042, 0x60000002, 0x80000001, 0x00000020, 0x00000003, 0x40000052, 0x40000040, 0xe0000052, 0xa0000000, 0x80000040, 0x20000001, 0x20000060, 0x80000001, 0x40000042, 0xc0000043, 0x40000022, 0x00000003, 0x40000042, 0xc0000043, 0xc0000022, 0x00000001, 0x40000002, 0xc0000043, 0x40000062, 0x80000001, 0x40000042, 0x40000042, 0x40000002, 0x00000002, 0x00000040, 0x80000002, 0x80000000, 0x80000002, 0x80000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000000, 0x00000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000101, 0x00000009, 0x00000012, 0x00000202, 0x0000001a, 0x00000124, 0x0000040c, 0x00000026, 0x0000004a, 0x0000080a}}, {1, 52, 0, 65, 0, 15, {0x04000010, 0xe8000000, 0x0800000c, 0x18000000, 0xb800000a, 0xc8000010, 0x2c000010, 0xf4000014, 0xb4000008, 0x08000000, 0x9800000c, 0xd8000010, 0x08000010, 0xb8000010, 0x98000000, 0x60000000, 0x00000008, 0xc0000000, 0x90000014, 0x10000010, 0xb8000014, 0x28000000, 0x20000010, 0x48000000, 0x08000018, 0x60000000, 0x90000010, 0xf0000010, 0x90000008, 0xc0000000, 0x90000010, 0xf0000010, 0xb0000008, 0x40000000, 0x90000000, 0xf0000010, 0x90000018, 0x60000000, 0x90000010, 0x90000010, 0x90000000, 0x80000000, 0x00000010, 0xa0000000, 0x20000000, 0xa0000000, 0x20000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x20000000, 0x00000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000040, 0x40000002, 0x80000004, 0x80000080, 0x80000006, 0x00000049, 0x00000103, 0x80000009, 0x80000012}}, {2, 45, 0, 58, 0, 16, {0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b, 0x0000011b, 0x8000016d, 0x8000041a, 0x000002e4, 0x80000054, 0x00000967}}, {2, 46, 0, 58, 0, 17, {0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b, 0x0000011b, 0x8000016d, 0x8000041a, 0x000002e4, 0x80000054}}, {2, 46, 2, 58, 0, 18, {0x90000070, 0xb0000053, 0x30000008, 0x00000043, 0xd0000072, 0xb0000010, 0xf0000062, 0xc0000042, 0x00000030, 0xe0000042, 0x20000060, 0xe0000041, 0x20000050, 0xc0000041, 0xe0000072, 0xa0000003, 0xc0000012, 0x60000041, 0xc0000032, 0x20000001, 0xc0000002, 0xe0000042, 0x60000042, 0x80000002, 0x00000000, 0x00000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000001, 0x00000060, 0x80000003, 0x40000002, 0xc0000040, 0xc0000002, 0x80000000, 0x80000000, 0x80000002, 0x00000040, 0x00000002, 0x80000000, 0x80000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000105, 0x00000089, 0x00000016, 0x0000020b, 0x0000011b, 0x0000012d, 0x0000041e, 0x00000224, 0x00000050, 0x0000092e, 0x0000046c, 0x000005b6, 0x0000106a, 0x00000b90, 0x00000152}}, {2, 47, 0, 58, 0, 19, {0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b, 0x0000011b, 0x8000016d, 0x8000041a, 0x000002e4}}, {2, 48, 0, 58, 0, 20, {0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b, 0x0000011b, 0x8000016d, 0x8000041a}}, {2, 49, 0, 58, 0, 21, {0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b, 0x0000011b, 0x8000016d}}, {2, 49, 2, 58, 0, 22, {0xf0000010, 0xf000006a, 0x80000040, 0x90000070, 0xb0000053, 0x30000008, 0x00000043, 0xd0000072, 0xb0000010, 0xf0000062, 0xc0000042, 0x00000030, 0xe0000042, 0x20000060, 0xe0000041, 0x20000050, 0xc0000041, 0xe0000072, 0xa0000003, 0xc0000012, 0x60000041, 0xc0000032, 0x20000001, 0xc0000002, 0xe0000042, 0x60000042, 0x80000002, 0x00000000, 0x00000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000001, 0x00000060, 0x80000003, 0x40000002, 0xc0000040, 0xc0000002, 0x80000000, 0x80000000, 0x80000002, 0x00000040, 0x00000002, 0x80000000, 0x80000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000105, 0x00000089, 0x00000016, 0x0000020b, 0x0000011b, 0x0000012d, 0x0000041e, 0x00000224, 0x00000050, 0x0000092e, 0x0000046c, 0x000005b6}}, {2, 50, 0, 65, 0, 23, {0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b, 0x0000011b}}, {2, 50, 2, 65, 0, 24, {0xd0000072, 0xf0000010, 0xf000006a, 0x80000040, 0x90000070, 0xb0000053, 0x30000008, 0x00000043, 0xd0000072, 0xb0000010, 0xf0000062, 0xc0000042, 0x00000030, 0xe0000042, 0x20000060, 0xe0000041, 0x20000050, 0xc0000041, 0xe0000072, 0xa0000003, 0xc0000012, 0x60000041, 0xc0000032, 0x20000001, 0xc0000002, 0xe0000042, 0x60000042, 0x80000002, 0x00000000, 0x00000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000001, 0x00000060, 0x80000003, 0x40000002, 0xc0000040, 0xc0000002, 0x80000000, 0x80000000, 0x80000002, 0x00000040, 0x00000002, 0x80000000, 0x80000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000105, 0x00000089, 0x00000016, 0x0000020b, 0x0000011b, 0x0000012d, 0x0000041e, 0x00000224, 0x00000050, 0x0000092e, 0x0000046c}}, {2, 51, 0, 65, 0, 25, {0xc0000010, 0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014, 0x8000024b}}, {2, 51, 2, 65, 0, 26, {0x00000043, 0xd0000072, 0xf0000010, 0xf000006a, 0x80000040, 0x90000070, 0xb0000053, 0x30000008, 0x00000043, 0xd0000072, 0xb0000010, 0xf0000062, 0xc0000042, 0x00000030, 0xe0000042, 0x20000060, 0xe0000041, 0x20000050, 0xc0000041, 0xe0000072, 0xa0000003, 0xc0000012, 0x60000041, 0xc0000032, 0x20000001, 0xc0000002, 0xe0000042, 0x60000042, 0x80000002, 0x00000000, 0x00000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000000, 0x00000040, 0x80000001, 0x00000060, 0x80000003, 0x40000002, 0xc0000040, 0xc0000002, 0x80000000, 0x80000000, 0x80000002, 0x00000040, 0x00000002, 0x80000000, 0x80000000, 0x80000000, 0x00000002, 0x00000040, 0x00000000, 0x80000040, 0x80000002, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000080, 0x00000004, 0x00000009, 0x00000105, 0x00000089, 0x00000016, 0x0000020b, 0x0000011b, 0x0000012d, 0x0000041e, 0x00000224, 0x00000050, 0x0000092e}}, {2, 52, 0, 65, 0, 27, {0x0c000002, 0xc0000010, 0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089, 0x00000014}}, {2, 53, 0, 65, 0, 28, {0xcc000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107, 0x00000089}}, {2, 54, 0, 65, 0, 29, {0x0400001c, 0xcc000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b, 0x80000107}}, {2, 55, 0, 65, 0, 30, {0x00000010, 0x0400001c, 0xcc000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046, 0x4000004b}}, {2, 56, 0, 65, 0, 31, {0x2600001a, 0x00000010, 0x0400001c, 0xcc000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x3c000004, 0xbc00001a, 0x20000010, 0x2400001c, 0xec000014, 0x0c000002, 0xc0000010, 0xb400001c, 0x2c000004, 0xbc000018, 0xb0000010, 0x0000000c, 0xb8000010, 0x08000018, 0x78000010, 0x08000014, 0x70000010, 0xb800001c, 0xe8000000, 0xb0000004, 0x58000010, 0xb000000c, 0x48000000, 0xb0000000, 0xb8000010, 0x98000010, 0xa0000000, 0x00000000, 0x00000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0x20000000, 0x00000010, 0x60000000, 0x00000018, 0xe0000000, 0x90000000, 0x30000010, 0xb0000000, 0x20000000, 0x20000000, 0xa0000000, 0x00000010, 0x80000000, 0x20000000, 0x20000000, 0x20000000, 0x80000000, 0x00000010, 0x00000000, 0x20000010, 0xa0000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000020, 0x00000001, 0x40000002, 0x40000041, 0x40000022, 0x80000005, 0xc0000082, 0xc0000046}}, {0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}}; -void ubc_check(const uint32_t W[80], uint32_t dvmask[1]) -{ - uint32_t mask = ~((uint32_t)(0)); - mask &= (((((W[44] ^ W[45]) >> 29) & 1) - 1) | ~(DV_I_48_0_bit | DV_I_51_0_bit | DV_I_52_0_bit | DV_II_45_0_bit | DV_II_46_0_bit | DV_II_50_0_bit | DV_II_51_0_bit)); - mask &= (((((W[49] ^ W[50]) >> 29) & 1) - 1) | ~(DV_I_46_0_bit | DV_II_45_0_bit | DV_II_50_0_bit | DV_II_51_0_bit | DV_II_55_0_bit | DV_II_56_0_bit)); - mask &= (((((W[48] ^ W[49]) >> 29) & 1) - 1) | ~(DV_I_45_0_bit | DV_I_52_0_bit | DV_II_49_0_bit | DV_II_50_0_bit | DV_II_54_0_bit | DV_II_55_0_bit)); - mask &= ((((W[47] ^ (W[50] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_51_0_bit | DV_II_56_0_bit)); - mask &= (((((W[47] ^ W[48]) >> 29) & 1) - 1) | ~(DV_I_44_0_bit | DV_I_51_0_bit | DV_II_48_0_bit | DV_II_49_0_bit | DV_II_53_0_bit | DV_II_54_0_bit)); - mask &= (((((W[46] >> 4) ^ (W[49] >> 29)) & 1) - 1) | ~(DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit | DV_II_50_0_bit | DV_II_55_0_bit)); - mask &= (((((W[46] ^ W[47]) >> 29) & 1) - 1) | ~(DV_I_43_0_bit | DV_I_50_0_bit | DV_II_47_0_bit | DV_II_48_0_bit | DV_II_52_0_bit | DV_II_53_0_bit)); - mask &= (((((W[45] >> 4) ^ (W[48] >> 29)) & 1) - 1) | ~(DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit | DV_II_49_0_bit | DV_II_54_0_bit)); - mask &= (((((W[45] ^ W[46]) >> 29) & 1) - 1) | ~(DV_I_49_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_47_0_bit | DV_II_51_0_bit | DV_II_52_0_bit)); - mask &= (((((W[44] >> 4) ^ (W[47] >> 29)) & 1) - 1) | ~(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit | DV_II_48_0_bit | DV_II_53_0_bit)); - mask &= (((((W[43] >> 4) ^ (W[46] >> 29)) & 1) - 1) | ~(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit | DV_II_47_0_bit | DV_II_52_0_bit)); - mask &= (((((W[43] ^ W[44]) >> 29) & 1) - 1) | ~(DV_I_47_0_bit | DV_I_50_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_49_0_bit | DV_II_50_0_bit)); - mask &= (((((W[42] >> 4) ^ (W[45] >> 29)) & 1) - 1) | ~(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_51_0_bit)); - mask &= (((((W[41] >> 4) ^ (W[44] >> 29)) & 1) - 1) | ~(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_50_0_bit)); - mask &= (((((W[40] ^ W[41]) >> 29) & 1) - 1) | ~(DV_I_44_0_bit | DV_I_47_0_bit | DV_I_48_0_bit | DV_II_46_0_bit | DV_II_47_0_bit | DV_II_56_0_bit)); - mask &= (((((W[54] ^ W[55]) >> 29) & 1) - 1) | ~(DV_I_51_0_bit | DV_II_47_0_bit | DV_II_50_0_bit | DV_II_55_0_bit | DV_II_56_0_bit)); - mask &= (((((W[53] ^ W[54]) >> 29) & 1) - 1) | ~(DV_I_50_0_bit | DV_II_46_0_bit | DV_II_49_0_bit | DV_II_54_0_bit | DV_II_55_0_bit)); - mask &= (((((W[52] ^ W[53]) >> 29) & 1) - 1) | ~(DV_I_49_0_bit | DV_II_45_0_bit | DV_II_48_0_bit | DV_II_53_0_bit | DV_II_54_0_bit)); - mask &= ((((W[50] ^ (W[53] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_50_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_48_0_bit | DV_II_54_0_bit)); - mask &= (((((W[50] ^ W[51]) >> 29) & 1) - 1) | ~(DV_I_47_0_bit | DV_II_46_0_bit | DV_II_51_0_bit | DV_II_52_0_bit | DV_II_56_0_bit)); - mask &= ((((W[49] ^ (W[52] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_47_0_bit | DV_II_53_0_bit)); - mask &= ((((W[48] ^ (W[51] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_52_0_bit)); - mask &= (((((W[42] ^ W[43]) >> 29) & 1) - 1) | ~(DV_I_46_0_bit | DV_I_49_0_bit | DV_I_50_0_bit | DV_II_48_0_bit | DV_II_49_0_bit)); - mask &= (((((W[41] ^ W[42]) >> 29) & 1) - 1) | ~(DV_I_45_0_bit | DV_I_48_0_bit | DV_I_49_0_bit | DV_II_47_0_bit | DV_II_48_0_bit)); - mask &= (((((W[40] >> 4) ^ (W[43] >> 29)) & 1) - 1) | ~(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_50_0_bit | DV_II_49_0_bit | DV_II_56_0_bit)); - mask &= (((((W[39] >> 4) ^ (W[42] >> 29)) & 1) - 1) | ~(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_49_0_bit | DV_II_48_0_bit | DV_II_55_0_bit)); - if (mask & (DV_I_44_0_bit | DV_I_48_0_bit | DV_II_47_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)) - mask &= (((((W[38] >> 4) ^ (W[41] >> 29)) & 1) - 1) | ~(DV_I_44_0_bit | DV_I_48_0_bit | DV_II_47_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)); - mask &= (((((W[37] >> 4) ^ (W[40] >> 29)) & 1) - 1) | ~(DV_I_43_0_bit | DV_I_47_0_bit | DV_II_46_0_bit | DV_II_53_0_bit | DV_II_55_0_bit)); - if (mask & (DV_I_52_0_bit | DV_II_48_0_bit | DV_II_51_0_bit | DV_II_56_0_bit)) - mask &= (((((W[55] ^ W[56]) >> 29) & 1) - 1) | ~(DV_I_52_0_bit | DV_II_48_0_bit | DV_II_51_0_bit | DV_II_56_0_bit)); - if (mask & (DV_I_52_0_bit | DV_II_48_0_bit | DV_II_50_0_bit | DV_II_56_0_bit)) - mask &= ((((W[52] ^ (W[55] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_52_0_bit | DV_II_48_0_bit | DV_II_50_0_bit | DV_II_56_0_bit)); - if (mask & (DV_I_51_0_bit | DV_II_47_0_bit | DV_II_49_0_bit | DV_II_55_0_bit)) - mask &= ((((W[51] ^ (W[54] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_51_0_bit | DV_II_47_0_bit | DV_II_49_0_bit | DV_II_55_0_bit)); - if (mask & (DV_I_48_0_bit | DV_II_47_0_bit | DV_II_52_0_bit | DV_II_53_0_bit)) - mask &= (((((W[51] ^ W[52]) >> 29) & 1) - 1) | ~(DV_I_48_0_bit | DV_II_47_0_bit | DV_II_52_0_bit | DV_II_53_0_bit)); - if (mask & (DV_I_46_0_bit | DV_I_49_0_bit | DV_II_45_0_bit | DV_II_48_0_bit)) - mask &= (((((W[36] >> 4) ^ (W[40] >> 29)) & 1) - 1) | ~(DV_I_46_0_bit | DV_I_49_0_bit | DV_II_45_0_bit | DV_II_48_0_bit)); - if (mask & (DV_I_52_0_bit | DV_II_48_0_bit | DV_II_49_0_bit)) - mask &= ((0 - (((W[53] ^ W[56]) >> 29) & 1)) | ~(DV_I_52_0_bit | DV_II_48_0_bit | DV_II_49_0_bit)); - if (mask & (DV_I_50_0_bit | DV_II_46_0_bit | DV_II_47_0_bit)) - mask &= ((0 - (((W[51] ^ W[54]) >> 29) & 1)) | ~(DV_I_50_0_bit | DV_II_46_0_bit | DV_II_47_0_bit)); - if (mask & (DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit)) - mask &= ((0 - (((W[50] ^ W[52]) >> 29) & 1)) | ~(DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit)); - if (mask & (DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit)) - mask &= ((0 - (((W[49] ^ W[51]) >> 29) & 1)) | ~(DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit)); - if (mask & (DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit)) - mask &= ((0 - (((W[48] ^ W[50]) >> 29) & 1)) | ~(DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit)); - if (mask & (DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit)) - mask &= ((0 - (((W[47] ^ W[49]) >> 29) & 1)) | ~(DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit)); - if (mask & (DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit)) - mask &= ((0 - (((W[46] ^ W[48]) >> 29) & 1)) | ~(DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit)); - mask &= ((((W[45] ^ W[47]) & (1 << 6)) - (1 << 6)) | ~(DV_I_47_2_bit | DV_I_49_2_bit | DV_I_51_2_bit)); - if (mask & (DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit)) - mask &= ((0 - (((W[45] ^ W[47]) >> 29) & 1)) | ~(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit)); - mask &= (((((W[44] ^ W[46]) >> 6) & 1) - 1) | ~(DV_I_46_2_bit | DV_I_48_2_bit | DV_I_50_2_bit)); - if (mask & (DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit)) - mask &= ((0 - (((W[44] ^ W[46]) >> 29) & 1)) | ~(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit)); - mask &= ((0 - ((W[41] ^ (W[42] >> 5)) & (1 << 1))) | ~(DV_I_48_2_bit | DV_II_46_2_bit | DV_II_51_2_bit)); - mask &= ((0 - ((W[40] ^ (W[41] >> 5)) & (1 << 1))) | ~(DV_I_47_2_bit | DV_I_51_2_bit | DV_II_50_2_bit)); - if (mask & (DV_I_44_0_bit | DV_I_46_0_bit | DV_II_56_0_bit)) - mask &= ((0 - (((W[40] ^ W[42]) >> 4) & 1)) | ~(DV_I_44_0_bit | DV_I_46_0_bit | DV_II_56_0_bit)); - mask &= ((0 - ((W[39] ^ (W[40] >> 5)) & (1 << 1))) | ~(DV_I_46_2_bit | DV_I_50_2_bit | DV_II_49_2_bit)); - if (mask & (DV_I_43_0_bit | DV_I_45_0_bit | DV_II_55_0_bit)) - mask &= ((0 - (((W[39] ^ W[41]) >> 4) & 1)) | ~(DV_I_43_0_bit | DV_I_45_0_bit | DV_II_55_0_bit)); - if (mask & (DV_I_44_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)) - mask &= ((0 - (((W[38] ^ W[40]) >> 4) & 1)) | ~(DV_I_44_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)); - if (mask & (DV_I_43_0_bit | DV_II_53_0_bit | DV_II_55_0_bit)) - mask &= ((0 - (((W[37] ^ W[39]) >> 4) & 1)) | ~(DV_I_43_0_bit | DV_II_53_0_bit | DV_II_55_0_bit)); - mask &= ((0 - ((W[36] ^ (W[37] >> 5)) & (1 << 1))) | ~(DV_I_47_2_bit | DV_I_50_2_bit | DV_II_46_2_bit)); - if (mask & (DV_I_45_0_bit | DV_I_48_0_bit | DV_II_47_0_bit)) - mask &= (((((W[35] >> 4) ^ (W[39] >> 29)) & 1) - 1) | ~(DV_I_45_0_bit | DV_I_48_0_bit | DV_II_47_0_bit)); - if (mask & (DV_I_48_0_bit | DV_II_48_0_bit)) - mask &= ((0 - ((W[63] ^ (W[64] >> 5)) & (1 << 0))) | ~(DV_I_48_0_bit | DV_II_48_0_bit)); - if (mask & (DV_I_45_0_bit | DV_II_45_0_bit)) - mask &= ((0 - ((W[63] ^ (W[64] >> 5)) & (1 << 1))) | ~(DV_I_45_0_bit | DV_II_45_0_bit)); - if (mask & (DV_I_47_0_bit | DV_II_47_0_bit)) - mask &= ((0 - ((W[62] ^ (W[63] >> 5)) & (1 << 0))) | ~(DV_I_47_0_bit | DV_II_47_0_bit)); - if (mask & (DV_I_46_0_bit | DV_II_46_0_bit)) - mask &= ((0 - ((W[61] ^ (W[62] >> 5)) & (1 << 0))) | ~(DV_I_46_0_bit | DV_II_46_0_bit)); - mask &= ((0 - ((W[61] ^ (W[62] >> 5)) & (1 << 2))) | ~(DV_I_46_2_bit | DV_II_46_2_bit)); - if (mask & (DV_I_45_0_bit | DV_II_45_0_bit)) - mask &= ((0 - ((W[60] ^ (W[61] >> 5)) & (1 << 0))) | ~(DV_I_45_0_bit | DV_II_45_0_bit)); - if (mask & (DV_II_51_0_bit | DV_II_54_0_bit)) - mask &= (((((W[58] ^ W[59]) >> 29) & 1) - 1) | ~(DV_II_51_0_bit | DV_II_54_0_bit)); - if (mask & (DV_II_50_0_bit | DV_II_53_0_bit)) - mask &= (((((W[57] ^ W[58]) >> 29) & 1) - 1) | ~(DV_II_50_0_bit | DV_II_53_0_bit)); - if (mask & (DV_II_52_0_bit | DV_II_54_0_bit)) - mask &= ((((W[56] ^ (W[59] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_II_52_0_bit | DV_II_54_0_bit)); - if (mask & (DV_II_51_0_bit | DV_II_52_0_bit)) - mask &= ((0 - (((W[56] ^ W[59]) >> 29) & 1)) | ~(DV_II_51_0_bit | DV_II_52_0_bit)); - if (mask & (DV_II_49_0_bit | DV_II_52_0_bit)) - mask &= (((((W[56] ^ W[57]) >> 29) & 1) - 1) | ~(DV_II_49_0_bit | DV_II_52_0_bit)); - if (mask & (DV_II_51_0_bit | DV_II_53_0_bit)) - mask &= ((((W[55] ^ (W[58] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_II_51_0_bit | DV_II_53_0_bit)); - if (mask & (DV_II_50_0_bit | DV_II_52_0_bit)) - mask &= ((((W[54] ^ (W[57] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_II_50_0_bit | DV_II_52_0_bit)); - if (mask & (DV_II_49_0_bit | DV_II_51_0_bit)) - mask &= ((((W[53] ^ (W[56] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_II_49_0_bit | DV_II_51_0_bit)); - mask &= ((((W[51] ^ (W[50] >> 5)) & (1 << 1)) - (1 << 1)) | ~(DV_I_50_2_bit | DV_II_46_2_bit)); - mask &= ((((W[48] ^ W[50]) & (1 << 6)) - (1 << 6)) | ~(DV_I_50_2_bit | DV_II_46_2_bit)); - if (mask & (DV_I_51_0_bit | DV_I_52_0_bit)) - mask &= ((0 - (((W[48] ^ W[55]) >> 29) & 1)) | ~(DV_I_51_0_bit | DV_I_52_0_bit)); - mask &= ((((W[47] ^ W[49]) & (1 << 6)) - (1 << 6)) | ~(DV_I_49_2_bit | DV_I_51_2_bit)); - mask &= ((((W[48] ^ (W[47] >> 5)) & (1 << 1)) - (1 << 1)) | ~(DV_I_47_2_bit | DV_II_51_2_bit)); - mask &= ((((W[46] ^ W[48]) & (1 << 6)) - (1 << 6)) | ~(DV_I_48_2_bit | DV_I_50_2_bit)); - mask &= ((((W[47] ^ (W[46] >> 5)) & (1 << 1)) - (1 << 1)) | ~(DV_I_46_2_bit | DV_II_50_2_bit)); - mask &= ((0 - ((W[44] ^ (W[45] >> 5)) & (1 << 1))) | ~(DV_I_51_2_bit | DV_II_49_2_bit)); - mask &= ((((W[43] ^ W[45]) & (1 << 6)) - (1 << 6)) | ~(DV_I_47_2_bit | DV_I_49_2_bit)); - mask &= (((((W[42] ^ W[44]) >> 6) & 1) - 1) | ~(DV_I_46_2_bit | DV_I_48_2_bit)); - mask &= ((((W[43] ^ (W[42] >> 5)) & (1 << 1)) - (1 << 1)) | ~(DV_II_46_2_bit | DV_II_51_2_bit)); - mask &= ((((W[42] ^ (W[41] >> 5)) & (1 << 1)) - (1 << 1)) | ~(DV_I_51_2_bit | DV_II_50_2_bit)); - mask &= ((((W[41] ^ (W[40] >> 5)) & (1 << 1)) - (1 << 1)) | ~(DV_I_50_2_bit | DV_II_49_2_bit)); - if (mask & (DV_I_52_0_bit | DV_II_51_0_bit)) - mask &= ((((W[39] ^ (W[43] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_52_0_bit | DV_II_51_0_bit)); - if (mask & (DV_I_51_0_bit | DV_II_50_0_bit)) - mask &= ((((W[38] ^ (W[42] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_51_0_bit | DV_II_50_0_bit)); - if (mask & (DV_I_48_2_bit | DV_I_51_2_bit)) - mask &= ((0 - ((W[37] ^ (W[38] >> 5)) & (1 << 1))) | ~(DV_I_48_2_bit | DV_I_51_2_bit)); - if (mask & (DV_I_50_0_bit | DV_II_49_0_bit)) - mask &= ((((W[37] ^ (W[41] >> 25)) & (1 << 4)) - (1 << 4)) | ~(DV_I_50_0_bit | DV_II_49_0_bit)); - if (mask & (DV_II_52_0_bit | DV_II_54_0_bit)) - mask &= ((0 - ((W[36] ^ W[38]) & (1 << 4))) | ~(DV_II_52_0_bit | DV_II_54_0_bit)); - mask &= ((0 - ((W[35] ^ (W[36] >> 5)) & (1 << 1))) | ~(DV_I_46_2_bit | DV_I_49_2_bit)); - if (mask & (DV_I_51_0_bit | DV_II_47_0_bit)) - mask &= ((((W[35] ^ (W[39] >> 25)) & (1 << 3)) - (1 << 3)) | ~(DV_I_51_0_bit | DV_II_47_0_bit)); - if (mask) - { - - if (mask & DV_I_43_0_bit) - if ( - !((W[61] ^ (W[62] >> 5)) & (1 << 1)) || !(!((W[59] ^ (W[63] >> 25)) & (1 << 5))) || !((W[58] ^ (W[63] >> 30)) & (1 << 0))) - mask &= ~DV_I_43_0_bit; - if (mask & DV_I_44_0_bit) - if ( - !((W[62] ^ (W[63] >> 5)) & (1 << 1)) || !(!((W[60] ^ (W[64] >> 25)) & (1 << 5))) || !((W[59] ^ (W[64] >> 30)) & (1 << 0))) - mask &= ~DV_I_44_0_bit; - if (mask & DV_I_46_2_bit) - mask &= ((~((W[40] ^ W[42]) >> 2)) | ~DV_I_46_2_bit); - if (mask & DV_I_47_2_bit) - if ( - !((W[62] ^ (W[63] >> 5)) & (1 << 2)) || !(!((W[41] ^ W[43]) & (1 << 6)))) - mask &= ~DV_I_47_2_bit; - if (mask & DV_I_48_2_bit) - if ( - !((W[63] ^ (W[64] >> 5)) & (1 << 2)) || !(!((W[48] ^ (W[49] << 5)) & (1 << 6)))) - mask &= ~DV_I_48_2_bit; - if (mask & DV_I_49_2_bit) - if ( - !(!((W[49] ^ (W[50] << 5)) & (1 << 6))) || !((W[42] ^ W[50]) & (1 << 1)) || !(!((W[39] ^ (W[40] << 5)) & (1 << 6))) || !((W[38] ^ W[40]) & (1 << 1))) - mask &= ~DV_I_49_2_bit; - if (mask & DV_I_50_0_bit) - mask &= ((((W[36] ^ W[37]) << 7)) | ~DV_I_50_0_bit); - if (mask & DV_I_50_2_bit) - mask &= ((((W[43] ^ W[51]) << 11)) | ~DV_I_50_2_bit); - if (mask & DV_I_51_0_bit) - mask &= ((((W[37] ^ W[38]) << 9)) | ~DV_I_51_0_bit); - if (mask & DV_I_51_2_bit) - if ( - !(!((W[51] ^ (W[52] << 5)) & (1 << 6))) || !(!((W[49] ^ W[51]) & (1 << 6))) || !(!((W[37] ^ (W[37] >> 5)) & (1 << 1))) || !(!((W[35] ^ (W[39] >> 25)) & (1 << 5)))) - mask &= ~DV_I_51_2_bit; - if (mask & DV_I_52_0_bit) - mask &= ((((W[38] ^ W[39]) << 11)) | ~DV_I_52_0_bit); - if (mask & DV_II_46_2_bit) - mask &= ((((W[47] ^ W[51]) << 17)) | ~DV_II_46_2_bit); - if (mask & DV_II_48_0_bit) - if ( - !(!((W[36] ^ (W[40] >> 25)) & (1 << 3))) || !((W[35] ^ (W[40] << 2)) & (1 << 30))) - mask &= ~DV_II_48_0_bit; - if (mask & DV_II_49_0_bit) - if ( - !(!((W[37] ^ (W[41] >> 25)) & (1 << 3))) || !((W[36] ^ (W[41] << 2)) & (1 << 30))) - mask &= ~DV_II_49_0_bit; - if (mask & DV_II_49_2_bit) - if ( - !(!((W[53] ^ (W[54] << 5)) & (1 << 6))) || !(!((W[51] ^ W[53]) & (1 << 6))) || !((W[50] ^ W[54]) & (1 << 1)) || !(!((W[45] ^ (W[46] << 5)) & (1 << 6))) || !(!((W[37] ^ (W[41] >> 25)) & (1 << 5))) || !((W[36] ^ (W[41] >> 30)) & (1 << 0))) - mask &= ~DV_II_49_2_bit; - if (mask & DV_II_50_0_bit) - if ( - !((W[55] ^ W[58]) & (1 << 29)) || !(!((W[38] ^ (W[42] >> 25)) & (1 << 3))) || !((W[37] ^ (W[42] << 2)) & (1 << 30))) - mask &= ~DV_II_50_0_bit; - if (mask & DV_II_50_2_bit) - if ( - !(!((W[54] ^ (W[55] << 5)) & (1 << 6))) || !(!((W[52] ^ W[54]) & (1 << 6))) || !((W[51] ^ W[55]) & (1 << 1)) || !((W[45] ^ W[47]) & (1 << 1)) || !(!((W[38] ^ (W[42] >> 25)) & (1 << 5))) || !((W[37] ^ (W[42] >> 30)) & (1 << 0))) - mask &= ~DV_II_50_2_bit; - if (mask & DV_II_51_0_bit) - if ( - !(!((W[39] ^ (W[43] >> 25)) & (1 << 3))) || !((W[38] ^ (W[43] << 2)) & (1 << 30))) - mask &= ~DV_II_51_0_bit; - if (mask & DV_II_51_2_bit) - if ( - !(!((W[55] ^ (W[56] << 5)) & (1 << 6))) || !(!((W[53] ^ W[55]) & (1 << 6))) || !((W[52] ^ W[56]) & (1 << 1)) || !((W[46] ^ W[48]) & (1 << 1)) || !(!((W[39] ^ (W[43] >> 25)) & (1 << 5))) || !((W[38] ^ (W[43] >> 30)) & (1 << 0))) - mask &= ~DV_II_51_2_bit; - if (mask & DV_II_52_0_bit) - if ( - !(!((W[59] ^ W[60]) & (1 << 29))) || !(!((W[40] ^ (W[44] >> 25)) & (1 << 3))) || !(!((W[40] ^ (W[44] >> 25)) & (1 << 4))) || !((W[39] ^ (W[44] << 2)) & (1 << 30))) - mask &= ~DV_II_52_0_bit; - if (mask & DV_II_53_0_bit) - if ( - !((W[58] ^ W[61]) & (1 << 29)) || !(!((W[57] ^ (W[61] >> 25)) & (1 << 4))) || !(!((W[41] ^ (W[45] >> 25)) & (1 << 3))) || !(!((W[41] ^ (W[45] >> 25)) & (1 << 4)))) - mask &= ~DV_II_53_0_bit; - if (mask & DV_II_54_0_bit) - if ( - !(!((W[58] ^ (W[62] >> 25)) & (1 << 4))) || !(!((W[42] ^ (W[46] >> 25)) & (1 << 3))) || !(!((W[42] ^ (W[46] >> 25)) & (1 << 4)))) - mask &= ~DV_II_54_0_bit; - if (mask & DV_II_55_0_bit) - if ( - !(!((W[59] ^ (W[63] >> 25)) & (1 << 4))) || !(!((W[57] ^ (W[59] >> 25)) & (1 << 4))) || !(!((W[43] ^ (W[47] >> 25)) & (1 << 3))) || !(!((W[43] ^ (W[47] >> 25)) & (1 << 4)))) - mask &= ~DV_II_55_0_bit; - if (mask & DV_II_56_0_bit) - if ( - !(!((W[60] ^ (W[64] >> 25)) & (1 << 4))) || !(!((W[44] ^ (W[48] >> 25)) & (1 << 3))) || !(!((W[44] ^ (W[48] >> 25)) & (1 << 4)))) - mask &= ~DV_II_56_0_bit; - } - - dvmask[0] = mask; -} - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C -#endif diff --git a/vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.h b/vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.h deleted file mode 100644 index a8863faf46..0000000000 --- a/vendor/github.com/pjbgf/sha1cd/cgo/ubc_check.h +++ /dev/null @@ -1,64 +0,0 @@ -/*** - * Copyright 2017 Marc Stevens , Dan Shumow - * Distributed under the MIT Software License. - * See accompanying file LICENSE.txt or copy at - * https://opensource.org/licenses/MIT - ***/ - -// Originally from: https://github.com/cr-marcstevens/sha1collisiondetection - -/* -// this file was generated by the 'parse_bitrel' program in the tools section -// using the data files from directory 'tools/data/3565' -// -// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check -// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper) -// dm[80] is the expanded message block XOR-difference defined by the DV -// testt is the step to do the recompression from for collision detection -// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check -// -// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs -// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met -// thus one needs to do the recompression check for each DV that has its bit set -*/ - -#ifndef SHA1DC_UBC_CHECK_H -#define SHA1DC_UBC_CHECK_H - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#endif - -#define DVMASKSIZE 1 - typedef struct - { - int dvType; - int dvK; - int dvB; - int testt; - int maski; - int maskb; - uint32_t dm[80]; - } dv_info_t; - extern dv_info_t sha1_dvs[]; - void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]); - -#define DOSTORESTATE58 -#define DOSTORESTATE65 - -#define CHECK_DVMASK(_DVMASK) (0 != _DVMASK[0]) - -#if defined(__cplusplus) -} -#endif - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H -#endif - -#endif diff --git a/vendor/golang.org/x/crypto/ssh/test/sshd_test_pw.c b/vendor/golang.org/x/crypto/ssh/test/sshd_test_pw.c deleted file mode 100644 index 2794a563a4..0000000000 --- a/vendor/golang.org/x/crypto/ssh/test/sshd_test_pw.c +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// sshd_test_pw.c -// Wrapper to inject test password data for sshd PAM authentication -// -// This wrapper implements custom versions of getpwnam, getpwnam_r, -// getspnam and getspnam_r. These functions first call their real -// libc versions, then check if the requested user matches test user -// specified in env variable TEST_USER and if so replace the password -// with crypted() value of TEST_PASSWD env variable. -// -// Compile: -// gcc -Wall -shared -o sshd_test_pw.so -fPIC sshd_test_pw.c -// -// Compile with debug: -// gcc -DVERBOSE -Wall -shared -o sshd_test_pw.so -fPIC sshd_test_pw.c -// -// Run sshd: -// LD_PRELOAD="sshd_test_pw.so" TEST_USER="..." TEST_PASSWD="..." sshd ... - -// +build ignore - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -#ifdef VERBOSE -#define DEBUG(X...) fprintf(stderr, X) -#else -#define DEBUG(X...) while (0) { } -#endif - -/* crypt() password */ -static char * -pwhash(char *passwd) { - return strdup(crypt(passwd, "$6$")); -} - -/* Pointers to real functions in libc */ -static struct passwd * (*real_getpwnam)(const char *) = NULL; -static int (*real_getpwnam_r)(const char *, struct passwd *, char *, size_t, struct passwd **) = NULL; -static struct spwd * (*real_getspnam)(const char *) = NULL; -static int (*real_getspnam_r)(const char *, struct spwd *, char *, size_t, struct spwd **) = NULL; - -/* Cached test user and test password */ -static char *test_user = NULL; -static char *test_passwd_hash = NULL; - -static void -init(void) { - /* Fetch real libc function pointers */ - real_getpwnam = dlsym(RTLD_NEXT, "getpwnam"); - real_getpwnam_r = dlsym(RTLD_NEXT, "getpwnam_r"); - real_getspnam = dlsym(RTLD_NEXT, "getspnam"); - real_getspnam_r = dlsym(RTLD_NEXT, "getspnam_r"); - - /* abort if env variables are not defined */ - if (getenv("TEST_USER") == NULL || getenv("TEST_PASSWD") == NULL) { - fprintf(stderr, "env variables TEST_USER and TEST_PASSWD are missing\n"); - abort(); - } - - /* Fetch test user and test password from env */ - test_user = strdup(getenv("TEST_USER")); - test_passwd_hash = pwhash(getenv("TEST_PASSWD")); - - DEBUG("sshd_test_pw init():\n"); - DEBUG("\treal_getpwnam: %p\n", real_getpwnam); - DEBUG("\treal_getpwnam_r: %p\n", real_getpwnam_r); - DEBUG("\treal_getspnam: %p\n", real_getspnam); - DEBUG("\treal_getspnam_r: %p\n", real_getspnam_r); - DEBUG("\tTEST_USER: '%s'\n", test_user); - DEBUG("\tTEST_PASSWD: '%s'\n", getenv("TEST_PASSWD")); - DEBUG("\tTEST_PASSWD_HASH: '%s'\n", test_passwd_hash); -} - -static int -is_test_user(const char *name) { - if (test_user != NULL && strcmp(test_user, name) == 0) - return 1; - return 0; -} - -/* getpwnam */ - -struct passwd * -getpwnam(const char *name) { - struct passwd *pw; - - DEBUG("sshd_test_pw getpwnam(%s)\n", name); - - if (real_getpwnam == NULL) - init(); - if ((pw = real_getpwnam(name)) == NULL) - return NULL; - - if (is_test_user(name)) - pw->pw_passwd = strdup(test_passwd_hash); - - return pw; -} - -/* getpwnam_r */ - -int -getpwnam_r(const char *name, - struct passwd *pwd, - char *buf, - size_t buflen, - struct passwd **result) { - int r; - - DEBUG("sshd_test_pw getpwnam_r(%s)\n", name); - - if (real_getpwnam_r == NULL) - init(); - if ((r = real_getpwnam_r(name, pwd, buf, buflen, result)) != 0 || *result == NULL) - return r; - - if (is_test_user(name)) - pwd->pw_passwd = strdup(test_passwd_hash); - - return 0; -} - -/* getspnam */ - -struct spwd * -getspnam(const char *name) { - struct spwd *sp; - - DEBUG("sshd_test_pw getspnam(%s)\n", name); - - if (real_getspnam == NULL) - init(); - if ((sp = real_getspnam(name)) == NULL) - return NULL; - - if (is_test_user(name)) - sp->sp_pwdp = strdup(test_passwd_hash); - - return sp; -} - -/* getspnam_r */ - -int -getspnam_r(const char *name, - struct spwd *spbuf, - char *buf, - size_t buflen, - struct spwd **spbufp) { - int r; - - DEBUG("sshd_test_pw getspnam_r(%s)\n", name); - - if (real_getspnam_r == NULL) - init(); - if ((r = real_getspnam_r(name, spbuf, buf, buflen, spbufp)) != 0) - return r; - - if (is_test_user(name)) - spbuf->sp_pwdp = strdup(test_passwd_hash); - - return r; -} diff --git a/vendor/golang.org/x/tools/go/loader/testdata/issue46877/x.h b/vendor/golang.org/x/tools/go/loader/testdata/issue46877/x.h deleted file mode 100644 index 9fc115b35f..0000000000 --- a/vendor/golang.org/x/tools/go/loader/testdata/issue46877/x.h +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -typedef int myint; diff --git a/vendor/modules.txt b/vendor/modules.txt index d3cc03a0a8..331a0a8ca1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -53,7 +53,7 @@ github.com/StackExchange/wmi # github.com/acomagu/bufpipe v1.0.4 ## explicit; go 1.12 github.com/acomagu/bufpipe -# github.com/actiontech/dms v0.0.0-20241010085644-dd7513f0051e +# github.com/actiontech/dms v0.0.0-20241017075851-7c8f25660c39 ## explicit; go 1.19 github.com/actiontech/dms/pkg/dms-common/api/accesstoken github.com/actiontech/dms/pkg/dms-common/api/base/v1 @@ -330,9 +330,6 @@ github.com/go-playground/validator/v10 # github.com/go-sql-driver/mysql v1.7.0 ## explicit; go 1.13 github.com/go-sql-driver/mysql -# github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 -## explicit; go 1.13 -github.com/gocarina/gocsv # github.com/golang-jwt/jwt v3.2.2+incompatible ## explicit github.com/golang-jwt/jwt From e5cc04ff3d484b7a18eae45335672ff083ef79f2 Mon Sep 17 00:00:00 2001 From: WinfredLIN Date: Thu, 17 Oct 2024 16:14:50 +0800 Subject: [PATCH 2/6] modify: types of variables project priority string to dmsV1.ProjectPriority instance id int64 to string --- sqle/api/controller/v1/sql_manage.go | 35 ++++++++++++++-------------- sqle/docs/docs.go | 2 +- sqle/docs/swagger.json | 2 +- sqle/docs/swagger.yaml | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/sqle/api/controller/v1/sql_manage.go b/sqle/api/controller/v1/sql_manage.go index f4b9965cca..dd7973970f 100644 --- a/sqle/api/controller/v1/sql_manage.go +++ b/sqle/api/controller/v1/sql_manage.go @@ -3,6 +3,7 @@ package v1 import ( "context" + dmsV1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1" "github.com/actiontech/sqle/sqle/api/controller" "github.com/actiontech/sqle/sqle/locale" "github.com/labstack/echo/v4" @@ -349,11 +350,11 @@ func convertSQLAnalysisResultToRes(ctx context.Context, res *AnalysisResult, raw } type GetGlobalSqlManageListReq struct { - FilterProjectUid *string `query:"filter_project_uid" json:"filter_project_uid,omitempty"` - FilterInstanceId *string `query:"filter_instance_id" json:"filter_instance_id,omitempty"` - FilterProjectPriority *string `query:"filter_project_priority" json:"filter_project_priority,omitempty" enums:"high,medium,low"` - PageIndex uint32 `query:"page_index" valid:"required" json:"page_index"` - PageSize uint32 `query:"page_size" valid:"required" json:"page_size"` + FilterProjectUid *string `query:"filter_project_uid" json:"filter_project_uid,omitempty"` + FilterInstanceId *string `query:"filter_instance_id" json:"filter_instance_id,omitempty"` + FilterProjectPriority *dmsV1.ProjectPriority `query:"filter_project_priority" json:"filter_project_priority,omitempty" enums:"high,medium,low"` + PageIndex uint32 `query:"page_index" valid:"required" json:"page_index"` + PageSize uint32 `query:"page_size" valid:"required" json:"page_size"` } type GetGlobalSqlManageListResp struct { @@ -363,18 +364,18 @@ type GetGlobalSqlManageListResp struct { } type GlobalSqlManage struct { - Id uint64 `json:"id"` - Sql string `json:"sql"` - Source *Source `json:"source"` - AuditResult []*AuditResult `json:"audit_result"` - ProjectName string `json:"project_name"` - ProjectUid string `json:"project_uid"` - InstanceName string `json:"instance_name"` - InstanceId string `json:"instance_id"` - Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited"` - ProjectPriority string `json:"project_priority" enums:"high,medium,low"` - FirstAppearTimeStamp string `json:"first_appear_timestamp"` - ProblemDescriptions []string `json:"problem_descriptions"` // 根据来源信息拼接 + Id uint64 `json:"id"` + Sql string `json:"sql"` + Source *Source `json:"source"` + AuditResult []*AuditResult `json:"audit_result"` + ProjectName string `json:"project_name"` + ProjectUid string `json:"project_uid"` + InstanceName string `json:"instance_name"` + InstanceId string `json:"instance_id"` + Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited"` + ProjectPriority dmsV1.ProjectPriority `json:"project_priority" enums:"high,medium,low"` + FirstAppearTimeStamp string `json:"first_appear_timestamp"` + ProblemDescriptions []string `json:"problem_descriptions"` // 根据来源信息拼接 } // GetGlobalSqlManageList diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 89e28c0c55..72c98c5928 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -14518,7 +14518,7 @@ var doc = `{ "type": "object", "properties": { "instance_id": { - "type": "integer" + "type": "string" }, "instance_name": { "type": "string" diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 897bda3717..7416a94edb 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -14502,7 +14502,7 @@ "type": "object", "properties": { "instance_id": { - "type": "integer" + "type": "string" }, "instance_name": { "type": "string" diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 08296c8167..fbf433c6ae 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -2726,7 +2726,7 @@ definitions: v1.InstanceInfo: properties: instance_id: - type: integer + type: string instance_name: type: string type: object From 5f9d9bc2ad31c13341722c38f45a583298dc833d Mon Sep 17 00:00:00 2001 From: WinfredLIN Date: Thu, 17 Oct 2024 16:16:28 +0800 Subject: [PATCH 3/6] model: get workflow filter by project id list, instance id and status list --- sqle/model/workflow_list.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sqle/model/workflow_list.go b/sqle/model/workflow_list.go index 7d95d90926..2be1479941 100644 --- a/sqle/model/workflow_list.go +++ b/sqle/model/workflow_list.go @@ -18,6 +18,7 @@ type WorkflowListDetail struct { Status string `json:"status"` TaskInstanceType RowList `json:"task_instance_type"` SqlVersionName RowList `json:"version"` + InstanceId RowList `json:"instance_id"` } var workflowsQueryTpl = ` @@ -32,9 +33,15 @@ SELECT curr_wst.type AS current_step_type, curr_ws.assignees AS current_step_assignee_user_id_list, wr.status, + GROUP_CONCAT(DISTINCT wir.instance_id SEPARATOR ',') AS instance_id, GROUP_CONCAT(DISTINCT versions.version SEPARATOR ',') AS version {{- template "body" . -}} GROUP BY w.id +{{- if .filter_instance_id }} +HAVING + FIND_IN_SET(:filter_instance_id, instance_id) > 0 +{{- end }} + ORDER BY w.id DESC {{- if .limit }} LIMIT :limit OFFSET :offset @@ -146,6 +153,21 @@ AND versions.id = :filter_sql_version_id {{- if .filter_project_id }} AND w.project_id = :filter_project_id {{- end }} +{{- if .filter_status_list }} +AND wr.status IN ( + {{ range $index, $element := .filter_status_list }} + {{ if $index }},{{ end }}"{{ $element }}" + {{ end }} + ) +{{- end }} + +{{- if .filter_project_id_list }} +AND w.project_id IN ( + {{ range $index, $element := .filter_project_id_list }} + {{ if $index }},{{ end }}"{{ $element }}" + {{ end }} + ) +{{- end }} {{- if .fuzzy_keyword }} AND (w.subject like :fuzzy_keyword or w.workflow_id like :fuzzy_keyword or w.desc like :fuzzy_keyword) From 14a59a07ab6eb1ff65b23231061604d45e56e666 Mon Sep 17 00:00:00 2001 From: WinfredLIN Date: Thu, 17 Oct 2024 16:16:42 +0800 Subject: [PATCH 4/6] feat: get global workflow can filter by statuses, project priority, instance id and project id --- sqle/api/controller/v1/workflow.go | 191 ++++++++++++++++++++++++----- 1 file changed, 158 insertions(+), 33 deletions(-) diff --git a/sqle/api/controller/v1/workflow.go b/sqle/api/controller/v1/workflow.go index 90589615a0..3794090f7f 100644 --- a/sqle/api/controller/v1/workflow.go +++ b/sqle/api/controller/v1/workflow.go @@ -22,6 +22,7 @@ import ( "github.com/actiontech/sqle/sqle/server" "github.com/actiontech/sqle/sqle/utils" + "github.com/actiontech/dms/pkg/dms-common/dmsobject" "github.com/labstack/echo/v4" ) @@ -494,24 +495,24 @@ func CheckWorkflowCanCommit(template *model.WorkflowTemplate, tasks []*model.Tas } type GetWorkflowsReqV1 struct { - FilterSubject string `json:"filter_subject" query:"filter_subject"` - FilterWorkflowID string `json:"filter_workflow_id" query:"filter_workflow_id"` - FilterCreateTimeFrom string `json:"filter_create_time_from" query:"filter_create_time_from"` - FilterCreateTimeTo string `json:"filter_create_time_to" query:"filter_create_time_to"` - FilterCreateUserId string `json:"filter_create_user_id" query:"filter_create_user_id"` - FilterStatus string `json:"filter_status" query:"filter_status" valid:"omitempty,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"` - FilterStatusList []string `json:"filter_status_list" query:"filter_status_list" validate:"dive,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"` - FilterCurrentStepAssigneeUserId string `json:"filter_current_step_assignee_user_id" query:"filter_current_step_assignee_user_id"` - FilterTaskInstanceId string `json:"filter_task_instance_id" query:"filter_task_instance_id"` - FilterTaskExecuteStartTimeFrom string `json:"filter_task_execute_start_time_from" query:"filter_task_execute_start_time_from"` - FilterTaskExecuteStartTimeTo string `json:"filter_task_execute_start_time_to" query:"filter_task_execute_start_time_to"` - FilterSqlVersionID *uint `json:"filter_sql_version_id" query:"filter_sql_version_id"` - FilterProjectUid string `json:"filter_project_uid" query:"filter_project_uid"` - FilterInstanceId string `json:"filter_instance_id" query:"filter_instance_id"` - FilterProjectPriority string `json:"filter_project_priority" query:"filter_project_priority" valid:"omitempty,oneof=high medium low"` - PageIndex uint32 `json:"page_index" query:"page_index" valid:"required"` - PageSize uint32 `json:"page_size" query:"page_size" valid:"required"` - FuzzyKeyword string `json:"fuzzy_keyword" query:"fuzzy_keyword"` + FilterSubject string `json:"filter_subject" query:"filter_subject"` + FilterWorkflowID string `json:"filter_workflow_id" query:"filter_workflow_id"` + FilterCreateTimeFrom string `json:"filter_create_time_from" query:"filter_create_time_from"` + FilterCreateTimeTo string `json:"filter_create_time_to" query:"filter_create_time_to"` + FilterCreateUserId string `json:"filter_create_user_id" query:"filter_create_user_id"` + FilterStatus string `json:"filter_status" query:"filter_status" valid:"omitempty,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"` + FilterStatusList []string `json:"filter_status_list" query:"filter_status_list" validate:"dive,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"` + FilterCurrentStepAssigneeUserId string `json:"filter_current_step_assignee_user_id" query:"filter_current_step_assignee_user_id"` + FilterTaskInstanceId string `json:"filter_task_instance_id" query:"filter_task_instance_id"` + FilterTaskExecuteStartTimeFrom string `json:"filter_task_execute_start_time_from" query:"filter_task_execute_start_time_from"` + FilterTaskExecuteStartTimeTo string `json:"filter_task_execute_start_time_to" query:"filter_task_execute_start_time_to"` + FilterSqlVersionID *uint `json:"filter_sql_version_id" query:"filter_sql_version_id"` + FilterProjectUid string `json:"filter_project_uid" query:"filter_project_uid"` + FilterInstanceId string `json:"filter_instance_id" query:"filter_instance_id"` + FilterProjectPriority dmsV1.ProjectPriority `json:"filter_project_priority" query:"filter_project_priority" valid:"omitempty,oneof=high medium low"` + PageIndex uint32 `json:"page_index" query:"page_index" valid:"required"` + PageSize uint32 `json:"page_size" query:"page_size" valid:"required"` + FuzzyKeyword string `json:"fuzzy_keyword" query:"fuzzy_keyword"` } type GetWorkflowsResV1 struct { @@ -521,23 +522,23 @@ type GetWorkflowsResV1 struct { } type WorkflowDetailResV1 struct { - ProjectName string `json:"project_name"` - ProjectUid string `json:"project_uid,omitempty"` - ProjectPriority string `json:"project_priority"` - Name string `json:"workflow_name"` - WorkflowId string `json:"workflow_id" ` - Desc string `json:"desc"` - SqlVersionName []string `json:"sql_version_name,omitempty"` - CreateUser string `json:"create_user_name"` - CreateTime *time.Time `json:"create_time"` - CurrentStepType string `json:"current_step_type,omitempty" enums:"sql_review,sql_execute"` - CurrentStepAssigneeUser []string `json:"current_step_assignee_user_name_list,omitempty"` - Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` - InstanceInfo []InstanceInfo `json:"instance_info,omitempty"` + ProjectName string `json:"project_name"` + ProjectUid string `json:"project_uid,omitempty"` + ProjectPriority dmsV1.ProjectPriority `json:"project_priority"` + Name string `json:"workflow_name"` + WorkflowId string `json:"workflow_id" ` + Desc string `json:"desc"` + SqlVersionName []string `json:"sql_version_name,omitempty"` + CreateUser string `json:"create_user_name"` + CreateTime *time.Time `json:"create_time"` + CurrentStepType string `json:"current_step_type,omitempty" enums:"sql_review,sql_execute"` + CurrentStepAssigneeUser []string `json:"current_step_assignee_user_name_list,omitempty"` + Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` + InstanceInfo []InstanceInfo `json:"instance_info,omitempty"` } type InstanceInfo struct { - InstanceId int64 `json:"instance_id,omitempty"` + InstanceId string `json:"instance_id,omitempty"` InstanceName string `json:"instance_name,omitempty"` } @@ -591,6 +592,25 @@ func GetGlobalWorkflowsV1(c echo.Context) error { "check_user_can_access": user.Name != model.DefaultAdminUser, // dms-todo: 判断是否是超级管理员 "limit": limit, "offset": offset, + "filter_status_list": req.FilterStatusList, // 根据SQL工单的状态筛选多个状态的工单 + "filter_project_id": req.FilterProjectUid, // 根据项目id筛选某些一个项目下的多个工单 + "filter_instance_id": req.FilterInstanceId, // 根据工单记录的数据源id,筛选包含该数据源的工单,多数据源情况下,一旦包含该数据源,则被选中 + } + + projectMap := make(map[string] /* project uid */ *dmsV1.ListProject) + // 若根据项目优先级筛选,则先请求dms,获取优先级对应的项目信息 + if req.FilterProjectPriority != "" { + data["filter_project_id_list"], projectMap, err = loadProjectsByPriority(c.Request().Context(), dmsV1.ProjectPriority(req.FilterProjectPriority)) + if err != nil { + return controller.JSONBaseErrorReq(c, err) + } + if len(projectMap) == 0 { + return c.JSON(http.StatusOK, GetWorkflowsResV1{ + BaseRes: controller.NewBaseReq(nil), + Data: []*WorkflowDetailResV1{}, + TotalNums: 0, + }) + } } s := model.GetStorage() @@ -604,10 +624,33 @@ func GetGlobalWorkflowsV1(c echo.Context) error { 2. 用户相关代码需要从DMS获取 */ + // 从dms获取工单对应的项目信息,若该信息已经在根据项目优先级筛选时被加载,则不需要重复加载 + if req.FilterProjectPriority == "" { + projectMap, err = loadProjectsByWorkflows(c.Request().Context(), workflows) + if err != nil { + return controller.JSONBaseErrorReq(c, err) + } + } + // 从dms获取工单对应的数据源信息 + instanceMap, err := loadInstanceByWorkflows(c.Request().Context(), workflows) + if err != nil { + return controller.JSONBaseErrorReq(c, err) + } + workflowsResV1 := make([]*WorkflowDetailResV1, 0, len(workflows)) for _, workflow := range workflows { + instanceInfos := make([]InstanceInfo, 0, len(workflow.InstanceId)) + for _, id := range workflow.InstanceId { + instanceInfos = append(instanceInfos, InstanceInfo{ + InstanceId: id, + InstanceName: instanceMap[id].Name, + }) + } workflowRes := &WorkflowDetailResV1{ - ProjectName: workflow.ProjectId, // dms-todo: 临时使用id代替name + ProjectName: projectMap[workflow.ProjectId].Name, + ProjectUid: workflow.ProjectId, + ProjectPriority: projectMap[workflow.ProjectId].ProjectPriority, + InstanceInfo: instanceInfos, Name: workflow.Subject, WorkflowId: workflow.WorkflowId, Desc: workflow.Desc, @@ -627,6 +670,88 @@ func GetGlobalWorkflowsV1(c echo.Context) error { }) } +// 根据项目优先级从 dms 系统中获取相应的项目列表,并返回项目ID列表和项目映射 +func loadProjectsByPriority(ctx context.Context, priority dmsV1.ProjectPriority) (projectIds []string, projectMap map[string] /* project uid */ *dmsV1.ListProject, err error) { + projectMap = make(map[string]*dmsV1.ListProject) + // 如果根据项目优先级筛选SQL工单,则先获取项目优先级,根据优先级对应的项目ID进行筛选 + projects, _, err := dmsobject.ListProjects(ctx, controller.GetDMSServerAddress(), dmsV1.ListProjectReq{ + PageSize: 999, + PageIndex: 1, + FilterByProjectPriority: priority, + }) + if err != nil { + return nil, nil, err + } + for _, project := range projects { + if _, exist := projectMap[project.ProjectUid]; !exist { + projectMap[project.ProjectUid] = project + } + projectIds = append(projectIds, project.ProjectUid) + } + return projectIds, projectMap, nil +} + +// 根据工单列表中的项目ID从 dms 系统中获取对应的项目信息,并返回项目映射 +func loadProjectsByWorkflows(ctx context.Context, workflows []*model.WorkflowListDetail) (projectMap map[string] /* project uid */ *dmsV1.ListProject, err error) { + projectMap = make(map[string]*dmsV1.ListProject) + if len(workflows) == 0 { + return projectMap, nil + } + + var projectIds []string + for _, workflow := range workflows { + if _, exist := projectMap[workflow.ProjectId]; !exist { + projectIds = append(projectIds, workflow.ProjectId) + projectMap[workflow.ProjectId] = nil + } + } + // get project priority from dms + projects, _, err := dmsobject.ListProjects(ctx, controller.GetDMSServerAddress(), dmsV1.ListProjectReq{ + PageSize: uint32(len(projectIds)), + PageIndex: 1, + FilterByProjectUids: projectIds, + }) + if err != nil { + return nil, err + } + projectMap = make(map[string] /* project uid */ *dmsV1.ListProject) + for _, project := range projects { + projectMap[project.ProjectUid] = project + } + return projectMap, nil +} + +// 根据工单列表中的实例ID从 dms 系统中获取对应的数据源实例信息,并返回实例映射 +func loadInstanceByWorkflows(ctx context.Context, workflows []*model.WorkflowListDetail) (instanceMap map[string] /* instance id */ *dmsV1.ListDBService, err error) { + instanceMap = make(map[string]*dmsV1.ListDBService) + if len(workflows) == 0 { + return instanceMap, nil + } + + var instanceIdList []string + for _, workflow := range workflows { + for _, id := range workflow.InstanceId { + if _, exist := instanceMap[id]; !exist { + instanceIdList = append(instanceIdList, id) + instanceMap[id] = nil + } + } + } + // get instances from dms + instances, _, err := dmsobject.ListDbServices(ctx, controller.GetDMSServerAddress(), dmsV1.ListDBServiceReq{ + PageSize: uint32(len(instanceIdList)), + PageIndex: 1, + FilterByDBServiceIds: instanceIdList, + }) + if err != nil { + return nil, err + } + for _, instance := range instances { + instanceMap[instance.DBServiceUid] = instance + } + return instanceMap, nil +} + // GetWorkflowsV1 // @Summary 获取工单列表 // @Description get workflow list From 920fa549887295a483d105b013182f35b97ccd9a Mon Sep 17 00:00:00 2001 From: WinfredLIN Date: Thu, 17 Oct 2024 16:30:11 +0800 Subject: [PATCH 5/6] ci: unnecessary conversion (unconvert) --- sqle/api/controller/v1/workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqle/api/controller/v1/workflow.go b/sqle/api/controller/v1/workflow.go index 3794090f7f..851197c57c 100644 --- a/sqle/api/controller/v1/workflow.go +++ b/sqle/api/controller/v1/workflow.go @@ -600,7 +600,7 @@ func GetGlobalWorkflowsV1(c echo.Context) error { projectMap := make(map[string] /* project uid */ *dmsV1.ListProject) // 若根据项目优先级筛选,则先请求dms,获取优先级对应的项目信息 if req.FilterProjectPriority != "" { - data["filter_project_id_list"], projectMap, err = loadProjectsByPriority(c.Request().Context(), dmsV1.ProjectPriority(req.FilterProjectPriority)) + data["filter_project_id_list"], projectMap, err = loadProjectsByPriority(c.Request().Context(), req.FilterProjectPriority) if err != nil { return controller.JSONBaseErrorReq(c, err) } From 459cb55a6a5491ffcc605574d97c586120f4a4b8 Mon Sep 17 00:00:00 2001 From: WinfredLIN Date: Fri, 18 Oct 2024 14:05:25 +0800 Subject: [PATCH 6/6] rename: instanceId and version add s as suffix --- sqle/api/controller/v1/workflow.go | 8 ++++---- sqle/model/workflow_list.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sqle/api/controller/v1/workflow.go b/sqle/api/controller/v1/workflow.go index 851197c57c..74f82a5e45 100644 --- a/sqle/api/controller/v1/workflow.go +++ b/sqle/api/controller/v1/workflow.go @@ -639,8 +639,8 @@ func GetGlobalWorkflowsV1(c echo.Context) error { workflowsResV1 := make([]*WorkflowDetailResV1, 0, len(workflows)) for _, workflow := range workflows { - instanceInfos := make([]InstanceInfo, 0, len(workflow.InstanceId)) - for _, id := range workflow.InstanceId { + instanceInfos := make([]InstanceInfo, 0, len(workflow.InstanceIds)) + for _, id := range workflow.InstanceIds { instanceInfos = append(instanceInfos, InstanceInfo{ InstanceId: id, InstanceName: instanceMap[id].Name, @@ -730,7 +730,7 @@ func loadInstanceByWorkflows(ctx context.Context, workflows []*model.WorkflowLis var instanceIdList []string for _, workflow := range workflows { - for _, id := range workflow.InstanceId { + for _, id := range workflow.InstanceIds { if _, exist := instanceMap[id]; !exist { instanceIdList = append(instanceIdList, id) instanceMap[id] = nil @@ -848,7 +848,7 @@ func GetWorkflowsV1(c echo.Context) error { CurrentStepType: workflow.CurrentStepType.String, CurrentStepAssigneeUser: CurrentStepAssigneeUserNames, Status: workflow.Status, - SqlVersionName: workflow.SqlVersionName, + SqlVersionName: workflow.SqlVersionNames, } workflowsResV1 = append(workflowsResV1, workflowRes) } diff --git a/sqle/model/workflow_list.go b/sqle/model/workflow_list.go index 2be1479941..5c5aeadf52 100644 --- a/sqle/model/workflow_list.go +++ b/sqle/model/workflow_list.go @@ -16,9 +16,9 @@ type WorkflowListDetail struct { CurrentStepType sql.NullString `json:"current_step_type" enums:"sql_review,sql_execute"` CurrentStepAssigneeUserIds sql.NullString `json:"current_step_assignee_user_id_list"` Status string `json:"status"` - TaskInstanceType RowList `json:"task_instance_type"` - SqlVersionName RowList `json:"version"` - InstanceId RowList `json:"instance_id"` + TaskInstanceType RowList `json:"task_instance_type"` // unused + SqlVersionNames RowList `json:"versions"` + InstanceIds RowList `json:"instance_ids"` } var workflowsQueryTpl = ` @@ -33,8 +33,8 @@ SELECT curr_wst.type AS current_step_type, curr_ws.assignees AS current_step_assignee_user_id_list, wr.status, - GROUP_CONCAT(DISTINCT wir.instance_id SEPARATOR ',') AS instance_id, - GROUP_CONCAT(DISTINCT versions.version SEPARATOR ',') AS version + GROUP_CONCAT(DISTINCT wir.instance_id SEPARATOR ',') AS instance_ids, + GROUP_CONCAT(DISTINCT versions.version SEPARATOR ',') AS versions {{- template "body" . -}} GROUP BY w.id {{- if .filter_instance_id }}