mirror of
https://github.com/X-Cli/large-file-decrypt.git
synced 2024-11-21 12:02:09 +00:00
Update vendors
This commit is contained in:
parent
b1f60357fa
commit
ef9e886aac
392 changed files with 172683 additions and 7 deletions
8
go.mod
8
go.mod
|
@ -1,9 +1,11 @@
|
||||||
module github.com/X-Cli/large-file-decrypt
|
module github.com/X-Cli/large-file-decrypt
|
||||||
|
|
||||||
go 1.15
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/hashicorp/go-multierror v1.1.1
|
github.com/hashicorp/go-multierror v1.1.1
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
|
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
|
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -2,14 +2,14 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
|
||||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
|
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 h1:syTAU9FwmvzEoIYMqcPHOcVm4H3U5u90WsvuYgwpETU=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 h1:8IVLkfbr2cLhv0a/vKq4UFUcJym8RmDoDboxCFWEjYE=
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
|
354
vendor/github.com/hashicorp/errwrap/LICENSE
generated
vendored
Normal file
354
vendor/github.com/hashicorp/errwrap/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,354 @@
|
||||||
|
Mozilla Public License, version 2.0
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
1.1. “Contributor”
|
||||||
|
|
||||||
|
means each individual or legal entity that creates, contributes to the
|
||||||
|
creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. “Contributor Version”
|
||||||
|
|
||||||
|
means the combination of the Contributions of others (if any) used by a
|
||||||
|
Contributor and that particular Contributor’s Contribution.
|
||||||
|
|
||||||
|
1.3. “Contribution”
|
||||||
|
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. “Covered Software”
|
||||||
|
|
||||||
|
means Source Code Form to which the initial Contributor has attached the
|
||||||
|
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||||
|
Modifications of such Source Code Form, in each case including portions
|
||||||
|
thereof.
|
||||||
|
|
||||||
|
1.5. “Incompatible With Secondary Licenses”
|
||||||
|
means
|
||||||
|
|
||||||
|
a. that the initial Contributor has attached the notice described in
|
||||||
|
Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
b. that the Covered Software was made available under the terms of version
|
||||||
|
1.1 or earlier of the License, but not also under the terms of a
|
||||||
|
Secondary License.
|
||||||
|
|
||||||
|
1.6. “Executable Form”
|
||||||
|
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. “Larger Work”
|
||||||
|
|
||||||
|
means a work that combines Covered Software with other material, in a separate
|
||||||
|
file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. “License”
|
||||||
|
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. “Licensable”
|
||||||
|
|
||||||
|
means having the right to grant, to the maximum extent possible, whether at the
|
||||||
|
time of the initial grant or subsequently, any and all of the rights conveyed by
|
||||||
|
this License.
|
||||||
|
|
||||||
|
1.10. “Modifications”
|
||||||
|
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
a. any file in Source Code Form that results from an addition to, deletion
|
||||||
|
from, or modification of the contents of Covered Software; or
|
||||||
|
|
||||||
|
b. any new file in Source Code Form that contains any Covered Software.
|
||||||
|
|
||||||
|
1.11. “Patent Claims” of a Contributor
|
||||||
|
|
||||||
|
means any patent claim(s), including without limitation, method, process,
|
||||||
|
and apparatus claims, in any patent Licensable by such Contributor that
|
||||||
|
would be infringed, but for the grant of the License, by the making,
|
||||||
|
using, selling, offering for sale, having made, import, or transfer of
|
||||||
|
either its Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
1.12. “Secondary License”
|
||||||
|
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||||
|
General Public License, Version 2.1, the GNU Affero General Public
|
||||||
|
License, Version 3.0, or any later versions of those licenses.
|
||||||
|
|
||||||
|
1.13. “Source Code Form”
|
||||||
|
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. “You” (or “Your”)
|
||||||
|
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, “You” includes any entity that controls, is
|
||||||
|
controlled by, or is under common control with You. For purposes of this
|
||||||
|
definition, “control” means (a) the power, direct or indirect, to cause
|
||||||
|
the direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||||
|
outstanding shares or beneficial ownership of such entity.
|
||||||
|
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
a. under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or as
|
||||||
|
part of a Larger Work; and
|
||||||
|
|
||||||
|
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||||
|
sale, have made, import, and otherwise transfer either its Contributions
|
||||||
|
or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||||
|
effective for each Contribution on the date the Contributor first distributes
|
||||||
|
such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under this
|
||||||
|
License. No additional rights or licenses will be implied from the distribution
|
||||||
|
or licensing of Covered Software under this License. Notwithstanding Section
|
||||||
|
2.1(b) above, no patent license is granted by a Contributor:
|
||||||
|
|
||||||
|
a. for any code that a Contributor has removed from Covered Software; or
|
||||||
|
|
||||||
|
b. for infringements caused by: (i) Your and any other third party’s
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
c. under Patent Claims infringed by Covered Software in the absence of its
|
||||||
|
Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks, or
|
||||||
|
logos of any Contributor (except as may be necessary to comply with the
|
||||||
|
notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this License
|
||||||
|
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
||||||
|
under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its Contributions
|
||||||
|
are its original creation(s) or it has sufficient rights to grant the
|
||||||
|
rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under applicable
|
||||||
|
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||||
|
Section 2.1.
|
||||||
|
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under the
|
||||||
|
terms of this License. You must inform recipients that the Source Code Form
|
||||||
|
of the Covered Software is governed by the terms of this License, and how
|
||||||
|
they can obtain a copy of this License. You may not attempt to alter or
|
||||||
|
restrict the recipients’ rights in the Source Code Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
a. such Covered Software must also be made available in Source Code Form,
|
||||||
|
as described in Section 3.1, and You must inform recipients of the
|
||||||
|
Executable Form how they can obtain a copy of such Source Code Form by
|
||||||
|
reasonable means in a timely manner, at a charge no more than the cost
|
||||||
|
of distribution to the recipient; and
|
||||||
|
|
||||||
|
b. You may distribute such Executable Form under the terms of this License,
|
||||||
|
or sublicense it under different terms, provided that the license for
|
||||||
|
the Executable Form does not attempt to limit or alter the recipients’
|
||||||
|
rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for the
|
||||||
|
Covered Software. If the Larger Work is a combination of Covered Software
|
||||||
|
with a work governed by one or more Secondary Licenses, and the Covered
|
||||||
|
Software is not Incompatible With Secondary Licenses, this License permits
|
||||||
|
You to additionally distribute such Covered Software under the terms of
|
||||||
|
such Secondary License(s), so that the recipient of the Larger Work may, at
|
||||||
|
their option, further distribute the Covered Software under the terms of
|
||||||
|
either this License or such Secondary License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices (including
|
||||||
|
copyright notices, patent notices, disclaimers of warranty, or limitations
|
||||||
|
of liability) contained within the Source Code Form of the Covered
|
||||||
|
Software, except that You may alter any license notices to the extent
|
||||||
|
required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on behalf
|
||||||
|
of any Contributor. You must make it absolutely clear that any such
|
||||||
|
warranty, support, indemnity, or liability obligation is offered by You
|
||||||
|
alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this License
|
||||||
|
with respect to some or all of the Covered Software due to statute, judicial
|
||||||
|
order, or regulation then You must: (a) comply with the terms of this License
|
||||||
|
to the maximum extent possible; and (b) describe the limitations and the code
|
||||||
|
they affect. Such description must be placed in a text file included with all
|
||||||
|
distributions of the Covered Software under this License. Except to the
|
||||||
|
extent prohibited by statute or regulation, such description must be
|
||||||
|
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||||
|
understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically if You
|
||||||
|
fail to comply with any of its terms. However, if You become compliant,
|
||||||
|
then the rights granted under this License from a particular Contributor
|
||||||
|
are reinstated (a) provisionally, unless and until such Contributor
|
||||||
|
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
||||||
|
if such Contributor fails to notify You of the non-compliance by some
|
||||||
|
reasonable means prior to 60 days after You have come back into compliance.
|
||||||
|
Moreover, Your grants from a particular Contributor are reinstated on an
|
||||||
|
ongoing basis if such Contributor notifies You of the non-compliance by
|
||||||
|
some reasonable means, this is the first time You have received notice of
|
||||||
|
non-compliance with this License from such Contributor, and You become
|
||||||
|
compliant prior to 30 days after Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions, counter-claims,
|
||||||
|
and cross-claims) alleging that a Contributor Version directly or
|
||||||
|
indirectly infringes any patent, then the rights granted to You by any and
|
||||||
|
all Contributors for the Covered Software under Section 2.1 of this License
|
||||||
|
shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||||
|
license agreements (excluding distributors and resellers) which have been
|
||||||
|
validly granted by You or Your distributors under this License prior to
|
||||||
|
termination shall survive termination.
|
||||||
|
|
||||||
|
6. Disclaimer of Warranty
|
||||||
|
|
||||||
|
Covered Software is provided under this License on an “as is” basis, without
|
||||||
|
warranty of any kind, either expressed, implied, or statutory, including,
|
||||||
|
without limitation, warranties that the Covered Software is free of defects,
|
||||||
|
merchantable, fit for a particular purpose or non-infringing. The entire
|
||||||
|
risk as to the quality and performance of the Covered Software is with You.
|
||||||
|
Should any Covered Software prove defective in any respect, You (not any
|
||||||
|
Contributor) assume the cost of any necessary servicing, repair, or
|
||||||
|
correction. This disclaimer of warranty constitutes an essential part of this
|
||||||
|
License. No use of any Covered Software is authorized under this License
|
||||||
|
except under this disclaimer.
|
||||||
|
|
||||||
|
7. Limitation of Liability
|
||||||
|
|
||||||
|
Under no circumstances and under no legal theory, whether tort (including
|
||||||
|
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||||
|
distributes Covered Software as permitted above, be liable to You for any
|
||||||
|
direct, indirect, special, incidental, or consequential damages of any
|
||||||
|
character including, without limitation, damages for lost profits, loss of
|
||||||
|
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses, even if such party shall have been
|
||||||
|
informed of the possibility of such damages. This limitation of liability
|
||||||
|
shall not apply to liability for death or personal injury resulting from such
|
||||||
|
party’s negligence to the extent applicable law prohibits such limitation.
|
||||||
|
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||||
|
consequential damages, so this exclusion and limitation may not apply to You.
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the courts of
|
||||||
|
a jurisdiction where the defendant maintains its principal place of business
|
||||||
|
and such litigation shall be governed by laws of that jurisdiction, without
|
||||||
|
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||||
|
prevent a party’s ability to bring cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject matter
|
||||||
|
hereof. If any provision of this License is held to be unenforceable, such
|
||||||
|
provision shall be reformed only to the extent necessary to make it
|
||||||
|
enforceable. Any law or regulation which provides that the language of a
|
||||||
|
contract shall be construed against the drafter shall not be used to construe
|
||||||
|
this License against a Contributor.
|
||||||
|
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version of
|
||||||
|
the License under which You originally received the Covered Software, or
|
||||||
|
under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a modified
|
||||||
|
version of this License if you rename the license and remove any
|
||||||
|
references to the name of the license steward (except to note that such
|
||||||
|
modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
|
||||||
|
This Source Code Form is subject to the
|
||||||
|
terms of the Mozilla Public License, v.
|
||||||
|
2.0. If a copy of the MPL was not
|
||||||
|
distributed with this file, You can
|
||||||
|
obtain one at
|
||||||
|
http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular file, then
|
||||||
|
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||||
|
directory) where a recipient would be likely to look for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||||
|
|
||||||
|
This Source Code Form is “Incompatible
|
||||||
|
With Secondary Licenses”, as defined by
|
||||||
|
the Mozilla Public License, v. 2.0.
|
||||||
|
|
89
vendor/github.com/hashicorp/errwrap/README.md
generated
vendored
Normal file
89
vendor/github.com/hashicorp/errwrap/README.md
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
# errwrap
|
||||||
|
|
||||||
|
`errwrap` is a package for Go that formalizes the pattern of wrapping errors
|
||||||
|
and checking if an error contains another error.
|
||||||
|
|
||||||
|
There is a common pattern in Go of taking a returned `error` value and
|
||||||
|
then wrapping it (such as with `fmt.Errorf`) before returning it. The problem
|
||||||
|
with this pattern is that you completely lose the original `error` structure.
|
||||||
|
|
||||||
|
Arguably the _correct_ approach is that you should make a custom structure
|
||||||
|
implementing the `error` interface, and have the original error as a field
|
||||||
|
on that structure, such [as this example](http://golang.org/pkg/os/#PathError).
|
||||||
|
This is a good approach, but you have to know the entire chain of possible
|
||||||
|
rewrapping that happens, when you might just care about one.
|
||||||
|
|
||||||
|
`errwrap` formalizes this pattern (it doesn't matter what approach you use
|
||||||
|
above) by giving a single interface for wrapping errors, checking if a specific
|
||||||
|
error is wrapped, and extracting that error.
|
||||||
|
|
||||||
|
## Installation and Docs
|
||||||
|
|
||||||
|
Install using `go get github.com/hashicorp/errwrap`.
|
||||||
|
|
||||||
|
Full documentation is available at
|
||||||
|
http://godoc.org/github.com/hashicorp/errwrap
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
#### Basic Usage
|
||||||
|
|
||||||
|
Below is a very basic example of its usage:
|
||||||
|
|
||||||
|
```go
|
||||||
|
// A function that always returns an error, but wraps it, like a real
|
||||||
|
// function might.
|
||||||
|
func tryOpen() error {
|
||||||
|
_, err := os.Open("/i/dont/exist")
|
||||||
|
if err != nil {
|
||||||
|
return errwrap.Wrapf("Doesn't exist: {{err}}", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
err := tryOpen()
|
||||||
|
|
||||||
|
// We can use the Contains helpers to check if an error contains
|
||||||
|
// another error. It is safe to do this with a nil error, or with
|
||||||
|
// an error that doesn't even use the errwrap package.
|
||||||
|
if errwrap.Contains(err, "does not exist") {
|
||||||
|
// Do something
|
||||||
|
}
|
||||||
|
if errwrap.ContainsType(err, new(os.PathError)) {
|
||||||
|
// Do something
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or we can use the associated `Get` functions to just extract
|
||||||
|
// a specific error. This would return nil if that specific error doesn't
|
||||||
|
// exist.
|
||||||
|
perr := errwrap.GetType(err, new(os.PathError))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Custom Types
|
||||||
|
|
||||||
|
If you're already making custom types that properly wrap errors, then
|
||||||
|
you can get all the functionality of `errwraps.Contains` and such by
|
||||||
|
implementing the `Wrapper` interface with just one function. Example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
type AppError {
|
||||||
|
Code ErrorCode
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *AppError) WrappedErrors() []error {
|
||||||
|
return []error{e.Err}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Now this works:
|
||||||
|
|
||||||
|
```go
|
||||||
|
err := &AppError{Err: fmt.Errorf("an error")}
|
||||||
|
if errwrap.ContainsType(err, fmt.Errorf("")) {
|
||||||
|
// This will work!
|
||||||
|
}
|
||||||
|
```
|
169
vendor/github.com/hashicorp/errwrap/errwrap.go
generated
vendored
Normal file
169
vendor/github.com/hashicorp/errwrap/errwrap.go
generated
vendored
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
// Package errwrap implements methods to formalize error wrapping in Go.
|
||||||
|
//
|
||||||
|
// All of the top-level functions that take an `error` are built to be able
|
||||||
|
// to take any error, not just wrapped errors. This allows you to use errwrap
|
||||||
|
// without having to type-check and type-cast everywhere.
|
||||||
|
package errwrap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WalkFunc is the callback called for Walk.
|
||||||
|
type WalkFunc func(error)
|
||||||
|
|
||||||
|
// Wrapper is an interface that can be implemented by custom types to
|
||||||
|
// have all the Contains, Get, etc. functions in errwrap work.
|
||||||
|
//
|
||||||
|
// When Walk reaches a Wrapper, it will call the callback for every
|
||||||
|
// wrapped error in addition to the wrapper itself. Since all the top-level
|
||||||
|
// functions in errwrap use Walk, this means that all those functions work
|
||||||
|
// with your custom type.
|
||||||
|
type Wrapper interface {
|
||||||
|
WrappedErrors() []error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap defines that outer wraps inner, returning an error type that
|
||||||
|
// can be cleanly used with the other methods in this package, such as
|
||||||
|
// Contains, GetAll, etc.
|
||||||
|
//
|
||||||
|
// This function won't modify the error message at all (the outer message
|
||||||
|
// will be used).
|
||||||
|
func Wrap(outer, inner error) error {
|
||||||
|
return &wrappedError{
|
||||||
|
Outer: outer,
|
||||||
|
Inner: inner,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrapf wraps an error with a formatting message. This is similar to using
|
||||||
|
// `fmt.Errorf` to wrap an error. If you're using `fmt.Errorf` to wrap
|
||||||
|
// errors, you should replace it with this.
|
||||||
|
//
|
||||||
|
// format is the format of the error message. The string '{{err}}' will
|
||||||
|
// be replaced with the original error message.
|
||||||
|
func Wrapf(format string, err error) error {
|
||||||
|
outerMsg := "<nil>"
|
||||||
|
if err != nil {
|
||||||
|
outerMsg = err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
outer := errors.New(strings.Replace(
|
||||||
|
format, "{{err}}", outerMsg, -1))
|
||||||
|
|
||||||
|
return Wrap(outer, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contains checks if the given error contains an error with the
|
||||||
|
// message msg. If err is not a wrapped error, this will always return
|
||||||
|
// false unless the error itself happens to match this msg.
|
||||||
|
func Contains(err error, msg string) bool {
|
||||||
|
return len(GetAll(err, msg)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainsType checks if the given error contains an error with
|
||||||
|
// the same concrete type as v. If err is not a wrapped error, this will
|
||||||
|
// check the err itself.
|
||||||
|
func ContainsType(err error, v interface{}) bool {
|
||||||
|
return len(GetAllType(err, v)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get is the same as GetAll but returns the deepest matching error.
|
||||||
|
func Get(err error, msg string) error {
|
||||||
|
es := GetAll(err, msg)
|
||||||
|
if len(es) > 0 {
|
||||||
|
return es[len(es)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetType is the same as GetAllType but returns the deepest matching error.
|
||||||
|
func GetType(err error, v interface{}) error {
|
||||||
|
es := GetAllType(err, v)
|
||||||
|
if len(es) > 0 {
|
||||||
|
return es[len(es)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAll gets all the errors that might be wrapped in err with the
|
||||||
|
// given message. The order of the errors is such that the outermost
|
||||||
|
// matching error (the most recent wrap) is index zero, and so on.
|
||||||
|
func GetAll(err error, msg string) []error {
|
||||||
|
var result []error
|
||||||
|
|
||||||
|
Walk(err, func(err error) {
|
||||||
|
if err.Error() == msg {
|
||||||
|
result = append(result, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllType gets all the errors that are the same type as v.
|
||||||
|
//
|
||||||
|
// The order of the return value is the same as described in GetAll.
|
||||||
|
func GetAllType(err error, v interface{}) []error {
|
||||||
|
var result []error
|
||||||
|
|
||||||
|
var search string
|
||||||
|
if v != nil {
|
||||||
|
search = reflect.TypeOf(v).String()
|
||||||
|
}
|
||||||
|
Walk(err, func(err error) {
|
||||||
|
var needle string
|
||||||
|
if err != nil {
|
||||||
|
needle = reflect.TypeOf(err).String()
|
||||||
|
}
|
||||||
|
|
||||||
|
if needle == search {
|
||||||
|
result = append(result, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk walks all the wrapped errors in err and calls the callback. If
|
||||||
|
// err isn't a wrapped error, this will be called once for err. If err
|
||||||
|
// is a wrapped error, the callback will be called for both the wrapper
|
||||||
|
// that implements error as well as the wrapped error itself.
|
||||||
|
func Walk(err error, cb WalkFunc) {
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch e := err.(type) {
|
||||||
|
case *wrappedError:
|
||||||
|
cb(e.Outer)
|
||||||
|
Walk(e.Inner, cb)
|
||||||
|
case Wrapper:
|
||||||
|
cb(err)
|
||||||
|
|
||||||
|
for _, err := range e.WrappedErrors() {
|
||||||
|
Walk(err, cb)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
cb(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrappedError is an implementation of error that has both the
|
||||||
|
// outer and inner errors.
|
||||||
|
type wrappedError struct {
|
||||||
|
Outer error
|
||||||
|
Inner error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *wrappedError) Error() string {
|
||||||
|
return w.Outer.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *wrappedError) WrappedErrors() []error {
|
||||||
|
return []error{w.Outer, w.Inner}
|
||||||
|
}
|
353
vendor/github.com/hashicorp/go-multierror/LICENSE
generated
vendored
Normal file
353
vendor/github.com/hashicorp/go-multierror/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,353 @@
|
||||||
|
Mozilla Public License, version 2.0
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
1.1. “Contributor”
|
||||||
|
|
||||||
|
means each individual or legal entity that creates, contributes to the
|
||||||
|
creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. “Contributor Version”
|
||||||
|
|
||||||
|
means the combination of the Contributions of others (if any) used by a
|
||||||
|
Contributor and that particular Contributor’s Contribution.
|
||||||
|
|
||||||
|
1.3. “Contribution”
|
||||||
|
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. “Covered Software”
|
||||||
|
|
||||||
|
means Source Code Form to which the initial Contributor has attached the
|
||||||
|
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||||
|
Modifications of such Source Code Form, in each case including portions
|
||||||
|
thereof.
|
||||||
|
|
||||||
|
1.5. “Incompatible With Secondary Licenses”
|
||||||
|
means
|
||||||
|
|
||||||
|
a. that the initial Contributor has attached the notice described in
|
||||||
|
Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
b. that the Covered Software was made available under the terms of version
|
||||||
|
1.1 or earlier of the License, but not also under the terms of a
|
||||||
|
Secondary License.
|
||||||
|
|
||||||
|
1.6. “Executable Form”
|
||||||
|
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. “Larger Work”
|
||||||
|
|
||||||
|
means a work that combines Covered Software with other material, in a separate
|
||||||
|
file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. “License”
|
||||||
|
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. “Licensable”
|
||||||
|
|
||||||
|
means having the right to grant, to the maximum extent possible, whether at the
|
||||||
|
time of the initial grant or subsequently, any and all of the rights conveyed by
|
||||||
|
this License.
|
||||||
|
|
||||||
|
1.10. “Modifications”
|
||||||
|
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
a. any file in Source Code Form that results from an addition to, deletion
|
||||||
|
from, or modification of the contents of Covered Software; or
|
||||||
|
|
||||||
|
b. any new file in Source Code Form that contains any Covered Software.
|
||||||
|
|
||||||
|
1.11. “Patent Claims” of a Contributor
|
||||||
|
|
||||||
|
means any patent claim(s), including without limitation, method, process,
|
||||||
|
and apparatus claims, in any patent Licensable by such Contributor that
|
||||||
|
would be infringed, but for the grant of the License, by the making,
|
||||||
|
using, selling, offering for sale, having made, import, or transfer of
|
||||||
|
either its Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
1.12. “Secondary License”
|
||||||
|
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||||
|
General Public License, Version 2.1, the GNU Affero General Public
|
||||||
|
License, Version 3.0, or any later versions of those licenses.
|
||||||
|
|
||||||
|
1.13. “Source Code Form”
|
||||||
|
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. “You” (or “Your”)
|
||||||
|
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, “You” includes any entity that controls, is
|
||||||
|
controlled by, or is under common control with You. For purposes of this
|
||||||
|
definition, “control” means (a) the power, direct or indirect, to cause
|
||||||
|
the direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||||
|
outstanding shares or beneficial ownership of such entity.
|
||||||
|
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
a. under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or as
|
||||||
|
part of a Larger Work; and
|
||||||
|
|
||||||
|
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||||
|
sale, have made, import, and otherwise transfer either its Contributions
|
||||||
|
or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||||
|
effective for each Contribution on the date the Contributor first distributes
|
||||||
|
such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under this
|
||||||
|
License. No additional rights or licenses will be implied from the distribution
|
||||||
|
or licensing of Covered Software under this License. Notwithstanding Section
|
||||||
|
2.1(b) above, no patent license is granted by a Contributor:
|
||||||
|
|
||||||
|
a. for any code that a Contributor has removed from Covered Software; or
|
||||||
|
|
||||||
|
b. for infringements caused by: (i) Your and any other third party’s
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
c. under Patent Claims infringed by Covered Software in the absence of its
|
||||||
|
Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks, or
|
||||||
|
logos of any Contributor (except as may be necessary to comply with the
|
||||||
|
notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this License
|
||||||
|
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
||||||
|
under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its Contributions
|
||||||
|
are its original creation(s) or it has sufficient rights to grant the
|
||||||
|
rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under applicable
|
||||||
|
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||||
|
Section 2.1.
|
||||||
|
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under the
|
||||||
|
terms of this License. You must inform recipients that the Source Code Form
|
||||||
|
of the Covered Software is governed by the terms of this License, and how
|
||||||
|
they can obtain a copy of this License. You may not attempt to alter or
|
||||||
|
restrict the recipients’ rights in the Source Code Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
a. such Covered Software must also be made available in Source Code Form,
|
||||||
|
as described in Section 3.1, and You must inform recipients of the
|
||||||
|
Executable Form how they can obtain a copy of such Source Code Form by
|
||||||
|
reasonable means in a timely manner, at a charge no more than the cost
|
||||||
|
of distribution to the recipient; and
|
||||||
|
|
||||||
|
b. You may distribute such Executable Form under the terms of this License,
|
||||||
|
or sublicense it under different terms, provided that the license for
|
||||||
|
the Executable Form does not attempt to limit or alter the recipients’
|
||||||
|
rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for the
|
||||||
|
Covered Software. If the Larger Work is a combination of Covered Software
|
||||||
|
with a work governed by one or more Secondary Licenses, and the Covered
|
||||||
|
Software is not Incompatible With Secondary Licenses, this License permits
|
||||||
|
You to additionally distribute such Covered Software under the terms of
|
||||||
|
such Secondary License(s), so that the recipient of the Larger Work may, at
|
||||||
|
their option, further distribute the Covered Software under the terms of
|
||||||
|
either this License or such Secondary License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices (including
|
||||||
|
copyright notices, patent notices, disclaimers of warranty, or limitations
|
||||||
|
of liability) contained within the Source Code Form of the Covered
|
||||||
|
Software, except that You may alter any license notices to the extent
|
||||||
|
required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on behalf
|
||||||
|
of any Contributor. You must make it absolutely clear that any such
|
||||||
|
warranty, support, indemnity, or liability obligation is offered by You
|
||||||
|
alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this License
|
||||||
|
with respect to some or all of the Covered Software due to statute, judicial
|
||||||
|
order, or regulation then You must: (a) comply with the terms of this License
|
||||||
|
to the maximum extent possible; and (b) describe the limitations and the code
|
||||||
|
they affect. Such description must be placed in a text file included with all
|
||||||
|
distributions of the Covered Software under this License. Except to the
|
||||||
|
extent prohibited by statute or regulation, such description must be
|
||||||
|
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||||
|
understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically if You
|
||||||
|
fail to comply with any of its terms. However, if You become compliant,
|
||||||
|
then the rights granted under this License from a particular Contributor
|
||||||
|
are reinstated (a) provisionally, unless and until such Contributor
|
||||||
|
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
||||||
|
if such Contributor fails to notify You of the non-compliance by some
|
||||||
|
reasonable means prior to 60 days after You have come back into compliance.
|
||||||
|
Moreover, Your grants from a particular Contributor are reinstated on an
|
||||||
|
ongoing basis if such Contributor notifies You of the non-compliance by
|
||||||
|
some reasonable means, this is the first time You have received notice of
|
||||||
|
non-compliance with this License from such Contributor, and You become
|
||||||
|
compliant prior to 30 days after Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions, counter-claims,
|
||||||
|
and cross-claims) alleging that a Contributor Version directly or
|
||||||
|
indirectly infringes any patent, then the rights granted to You by any and
|
||||||
|
all Contributors for the Covered Software under Section 2.1 of this License
|
||||||
|
shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||||
|
license agreements (excluding distributors and resellers) which have been
|
||||||
|
validly granted by You or Your distributors under this License prior to
|
||||||
|
termination shall survive termination.
|
||||||
|
|
||||||
|
6. Disclaimer of Warranty
|
||||||
|
|
||||||
|
Covered Software is provided under this License on an “as is” basis, without
|
||||||
|
warranty of any kind, either expressed, implied, or statutory, including,
|
||||||
|
without limitation, warranties that the Covered Software is free of defects,
|
||||||
|
merchantable, fit for a particular purpose or non-infringing. The entire
|
||||||
|
risk as to the quality and performance of the Covered Software is with You.
|
||||||
|
Should any Covered Software prove defective in any respect, You (not any
|
||||||
|
Contributor) assume the cost of any necessary servicing, repair, or
|
||||||
|
correction. This disclaimer of warranty constitutes an essential part of this
|
||||||
|
License. No use of any Covered Software is authorized under this License
|
||||||
|
except under this disclaimer.
|
||||||
|
|
||||||
|
7. Limitation of Liability
|
||||||
|
|
||||||
|
Under no circumstances and under no legal theory, whether tort (including
|
||||||
|
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||||
|
distributes Covered Software as permitted above, be liable to You for any
|
||||||
|
direct, indirect, special, incidental, or consequential damages of any
|
||||||
|
character including, without limitation, damages for lost profits, loss of
|
||||||
|
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses, even if such party shall have been
|
||||||
|
informed of the possibility of such damages. This limitation of liability
|
||||||
|
shall not apply to liability for death or personal injury resulting from such
|
||||||
|
party’s negligence to the extent applicable law prohibits such limitation.
|
||||||
|
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||||
|
consequential damages, so this exclusion and limitation may not apply to You.
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the courts of
|
||||||
|
a jurisdiction where the defendant maintains its principal place of business
|
||||||
|
and such litigation shall be governed by laws of that jurisdiction, without
|
||||||
|
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||||
|
prevent a party’s ability to bring cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject matter
|
||||||
|
hereof. If any provision of this License is held to be unenforceable, such
|
||||||
|
provision shall be reformed only to the extent necessary to make it
|
||||||
|
enforceable. Any law or regulation which provides that the language of a
|
||||||
|
contract shall be construed against the drafter shall not be used to construe
|
||||||
|
this License against a Contributor.
|
||||||
|
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version of
|
||||||
|
the License under which You originally received the Covered Software, or
|
||||||
|
under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a modified
|
||||||
|
version of this License if you rename the license and remove any
|
||||||
|
references to the name of the license steward (except to note that such
|
||||||
|
modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
|
||||||
|
This Source Code Form is subject to the
|
||||||
|
terms of the Mozilla Public License, v.
|
||||||
|
2.0. If a copy of the MPL was not
|
||||||
|
distributed with this file, You can
|
||||||
|
obtain one at
|
||||||
|
http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular file, then
|
||||||
|
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||||
|
directory) where a recipient would be likely to look for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||||
|
|
||||||
|
This Source Code Form is “Incompatible
|
||||||
|
With Secondary Licenses”, as defined by
|
||||||
|
the Mozilla Public License, v. 2.0.
|
31
vendor/github.com/hashicorp/go-multierror/Makefile
generated
vendored
Normal file
31
vendor/github.com/hashicorp/go-multierror/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
TEST?=./...
|
||||||
|
|
||||||
|
default: test
|
||||||
|
|
||||||
|
# test runs the test suite and vets the code.
|
||||||
|
test: generate
|
||||||
|
@echo "==> Running tests..."
|
||||||
|
@go list $(TEST) \
|
||||||
|
| grep -v "/vendor/" \
|
||||||
|
| xargs -n1 go test -timeout=60s -parallel=10 ${TESTARGS}
|
||||||
|
|
||||||
|
# testrace runs the race checker
|
||||||
|
testrace: generate
|
||||||
|
@echo "==> Running tests (race)..."
|
||||||
|
@go list $(TEST) \
|
||||||
|
| grep -v "/vendor/" \
|
||||||
|
| xargs -n1 go test -timeout=60s -race ${TESTARGS}
|
||||||
|
|
||||||
|
# updatedeps installs all the dependencies needed to run and build.
|
||||||
|
updatedeps:
|
||||||
|
@sh -c "'${CURDIR}/scripts/deps.sh' '${NAME}'"
|
||||||
|
|
||||||
|
# generate runs `go generate` to build the dynamically generated source files.
|
||||||
|
generate:
|
||||||
|
@echo "==> Generating..."
|
||||||
|
@find . -type f -name '.DS_Store' -delete
|
||||||
|
@go list ./... \
|
||||||
|
| grep -v "/vendor/" \
|
||||||
|
| xargs -n1 go generate
|
||||||
|
|
||||||
|
.PHONY: default test testrace updatedeps generate
|
150
vendor/github.com/hashicorp/go-multierror/README.md
generated
vendored
Normal file
150
vendor/github.com/hashicorp/go-multierror/README.md
generated
vendored
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
# go-multierror
|
||||||
|
|
||||||
|
[![CircleCI](https://img.shields.io/circleci/build/github/hashicorp/go-multierror/master)](https://circleci.com/gh/hashicorp/go-multierror)
|
||||||
|
[![Go Reference](https://pkg.go.dev/badge/github.com/hashicorp/go-multierror.svg)](https://pkg.go.dev/github.com/hashicorp/go-multierror)
|
||||||
|
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/hashicorp/go-multierror)
|
||||||
|
|
||||||
|
[circleci]: https://app.circleci.com/pipelines/github/hashicorp/go-multierror
|
||||||
|
[godocs]: https://pkg.go.dev/github.com/hashicorp/go-multierror
|
||||||
|
|
||||||
|
`go-multierror` is a package for Go that provides a mechanism for
|
||||||
|
representing a list of `error` values as a single `error`.
|
||||||
|
|
||||||
|
This allows a function in Go to return an `error` that might actually
|
||||||
|
be a list of errors. If the caller knows this, they can unwrap the
|
||||||
|
list and access the errors. If the caller doesn't know, the error
|
||||||
|
formats to a nice human-readable format.
|
||||||
|
|
||||||
|
`go-multierror` is fully compatible with the Go standard library
|
||||||
|
[errors](https://golang.org/pkg/errors/) package, including the
|
||||||
|
functions `As`, `Is`, and `Unwrap`. This provides a standardized approach
|
||||||
|
for introspecting on error values.
|
||||||
|
|
||||||
|
## Installation and Docs
|
||||||
|
|
||||||
|
Install using `go get github.com/hashicorp/go-multierror`.
|
||||||
|
|
||||||
|
Full documentation is available at
|
||||||
|
https://pkg.go.dev/github.com/hashicorp/go-multierror
|
||||||
|
|
||||||
|
### Requires go version 1.13 or newer
|
||||||
|
|
||||||
|
`go-multierror` requires go version 1.13 or newer. Go 1.13 introduced
|
||||||
|
[error wrapping](https://golang.org/doc/go1.13#error_wrapping), which
|
||||||
|
this library takes advantage of.
|
||||||
|
|
||||||
|
If you need to use an earlier version of go, you can use the
|
||||||
|
[v1.0.0](https://github.com/hashicorp/go-multierror/tree/v1.0.0)
|
||||||
|
tag, which doesn't rely on features in go 1.13.
|
||||||
|
|
||||||
|
If you see compile errors that look like the below, it's likely that
|
||||||
|
you're on an older version of go:
|
||||||
|
|
||||||
|
```
|
||||||
|
/go/src/github.com/hashicorp/go-multierror/multierror.go:112:9: undefined: errors.As
|
||||||
|
/go/src/github.com/hashicorp/go-multierror/multierror.go:117:9: undefined: errors.Is
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
go-multierror is easy to use and purposely built to be unobtrusive in
|
||||||
|
existing Go applications/libraries that may not be aware of it.
|
||||||
|
|
||||||
|
**Building a list of errors**
|
||||||
|
|
||||||
|
The `Append` function is used to create a list of errors. This function
|
||||||
|
behaves a lot like the Go built-in `append` function: it doesn't matter
|
||||||
|
if the first argument is nil, a `multierror.Error`, or any other `error`,
|
||||||
|
the function behaves as you would expect.
|
||||||
|
|
||||||
|
```go
|
||||||
|
var result error
|
||||||
|
|
||||||
|
if err := step1(); err != nil {
|
||||||
|
result = multierror.Append(result, err)
|
||||||
|
}
|
||||||
|
if err := step2(); err != nil {
|
||||||
|
result = multierror.Append(result, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
```
|
||||||
|
|
||||||
|
**Customizing the formatting of the errors**
|
||||||
|
|
||||||
|
By specifying a custom `ErrorFormat`, you can customize the format
|
||||||
|
of the `Error() string` function:
|
||||||
|
|
||||||
|
```go
|
||||||
|
var result *multierror.Error
|
||||||
|
|
||||||
|
// ... accumulate errors here, maybe using Append
|
||||||
|
|
||||||
|
if result != nil {
|
||||||
|
result.ErrorFormat = func([]error) string {
|
||||||
|
return "errors!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Accessing the list of errors**
|
||||||
|
|
||||||
|
`multierror.Error` implements `error` so if the caller doesn't know about
|
||||||
|
multierror, it will work just fine. But if you're aware a multierror might
|
||||||
|
be returned, you can use type switches to access the list of errors:
|
||||||
|
|
||||||
|
```go
|
||||||
|
if err := something(); err != nil {
|
||||||
|
if merr, ok := err.(*multierror.Error); ok {
|
||||||
|
// Use merr.Errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use the standard [`errors.Unwrap`](https://golang.org/pkg/errors/#Unwrap)
|
||||||
|
function. This will continue to unwrap into subsequent errors until none exist.
|
||||||
|
|
||||||
|
**Extracting an error**
|
||||||
|
|
||||||
|
The standard library [`errors.As`](https://golang.org/pkg/errors/#As)
|
||||||
|
function can be used directly with a multierror to extract a specific error:
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Assume err is a multierror value
|
||||||
|
err := somefunc()
|
||||||
|
|
||||||
|
// We want to know if "err" has a "RichErrorType" in it and extract it.
|
||||||
|
var errRich RichErrorType
|
||||||
|
if errors.As(err, &errRich) {
|
||||||
|
// It has it, and now errRich is populated.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Checking for an exact error value**
|
||||||
|
|
||||||
|
Some errors are returned as exact errors such as the [`ErrNotExist`](https://golang.org/pkg/os/#pkg-variables)
|
||||||
|
error in the `os` package. You can check if this error is present by using
|
||||||
|
the standard [`errors.Is`](https://golang.org/pkg/errors/#Is) function.
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Assume err is a multierror value
|
||||||
|
err := somefunc()
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
// err contains os.ErrNotExist
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returning a multierror only if there are errors**
|
||||||
|
|
||||||
|
If you build a `multierror.Error`, you can use the `ErrorOrNil` function
|
||||||
|
to return an `error` implementation only if there are errors to return:
|
||||||
|
|
||||||
|
```go
|
||||||
|
var result *multierror.Error
|
||||||
|
|
||||||
|
// ... accumulate errors here
|
||||||
|
|
||||||
|
// Return the `error` only if errors were added to the multierror, otherwise
|
||||||
|
// return nil since there are no errors.
|
||||||
|
return result.ErrorOrNil()
|
||||||
|
```
|
43
vendor/github.com/hashicorp/go-multierror/append.go
generated
vendored
Normal file
43
vendor/github.com/hashicorp/go-multierror/append.go
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
// Append is a helper function that will append more errors
|
||||||
|
// onto an Error in order to create a larger multi-error.
|
||||||
|
//
|
||||||
|
// If err is not a multierror.Error, then it will be turned into
|
||||||
|
// one. If any of the errs are multierr.Error, they will be flattened
|
||||||
|
// one level into err.
|
||||||
|
// Any nil errors within errs will be ignored. If err is nil, a new
|
||||||
|
// *Error will be returned.
|
||||||
|
func Append(err error, errs ...error) *Error {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *Error:
|
||||||
|
// Typed nils can reach here, so initialize if we are nil
|
||||||
|
if err == nil {
|
||||||
|
err = new(Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go through each error and flatten
|
||||||
|
for _, e := range errs {
|
||||||
|
switch e := e.(type) {
|
||||||
|
case *Error:
|
||||||
|
if e != nil {
|
||||||
|
err.Errors = append(err.Errors, e.Errors...)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if e != nil {
|
||||||
|
err.Errors = append(err.Errors, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
newErrs := make([]error, 0, len(errs)+1)
|
||||||
|
if err != nil {
|
||||||
|
newErrs = append(newErrs, err)
|
||||||
|
}
|
||||||
|
newErrs = append(newErrs, errs...)
|
||||||
|
|
||||||
|
return Append(&Error{}, newErrs...)
|
||||||
|
}
|
||||||
|
}
|
26
vendor/github.com/hashicorp/go-multierror/flatten.go
generated
vendored
Normal file
26
vendor/github.com/hashicorp/go-multierror/flatten.go
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
// Flatten flattens the given error, merging any *Errors together into
|
||||||
|
// a single *Error.
|
||||||
|
func Flatten(err error) error {
|
||||||
|
// If it isn't an *Error, just return the error as-is
|
||||||
|
if _, ok := err.(*Error); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, make the result and flatten away!
|
||||||
|
flatErr := new(Error)
|
||||||
|
flatten(err, flatErr)
|
||||||
|
return flatErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func flatten(err error, flatErr *Error) {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *Error:
|
||||||
|
for _, e := range err.Errors {
|
||||||
|
flatten(e, flatErr)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
flatErr.Errors = append(flatErr.Errors, err)
|
||||||
|
}
|
||||||
|
}
|
27
vendor/github.com/hashicorp/go-multierror/format.go
generated
vendored
Normal file
27
vendor/github.com/hashicorp/go-multierror/format.go
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ErrorFormatFunc is a function callback that is called by Error to
|
||||||
|
// turn the list of errors into a string.
|
||||||
|
type ErrorFormatFunc func([]error) string
|
||||||
|
|
||||||
|
// ListFormatFunc is a basic formatter that outputs the number of errors
|
||||||
|
// that occurred along with a bullet point list of the errors.
|
||||||
|
func ListFormatFunc(es []error) string {
|
||||||
|
if len(es) == 1 {
|
||||||
|
return fmt.Sprintf("1 error occurred:\n\t* %s\n\n", es[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
points := make([]string, len(es))
|
||||||
|
for i, err := range es {
|
||||||
|
points[i] = fmt.Sprintf("* %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%d errors occurred:\n\t%s\n\n",
|
||||||
|
len(es), strings.Join(points, "\n\t"))
|
||||||
|
}
|
38
vendor/github.com/hashicorp/go-multierror/group.go
generated
vendored
Normal file
38
vendor/github.com/hashicorp/go-multierror/group.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
import "sync"
|
||||||
|
|
||||||
|
// Group is a collection of goroutines which return errors that need to be
|
||||||
|
// coalesced.
|
||||||
|
type Group struct {
|
||||||
|
mutex sync.Mutex
|
||||||
|
err *Error
|
||||||
|
wg sync.WaitGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go calls the given function in a new goroutine.
|
||||||
|
//
|
||||||
|
// If the function returns an error it is added to the group multierror which
|
||||||
|
// is returned by Wait.
|
||||||
|
func (g *Group) Go(f func() error) {
|
||||||
|
g.wg.Add(1)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer g.wg.Done()
|
||||||
|
|
||||||
|
if err := f(); err != nil {
|
||||||
|
g.mutex.Lock()
|
||||||
|
g.err = Append(g.err, err)
|
||||||
|
g.mutex.Unlock()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait blocks until all function calls from the Go method have returned, then
|
||||||
|
// returns the multierror.
|
||||||
|
func (g *Group) Wait() *Error {
|
||||||
|
g.wg.Wait()
|
||||||
|
g.mutex.Lock()
|
||||||
|
defer g.mutex.Unlock()
|
||||||
|
return g.err
|
||||||
|
}
|
121
vendor/github.com/hashicorp/go-multierror/multierror.go
generated
vendored
Normal file
121
vendor/github.com/hashicorp/go-multierror/multierror.go
generated
vendored
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Error is an error type to track multiple errors. This is used to
|
||||||
|
// accumulate errors in cases and return them as a single "error".
|
||||||
|
type Error struct {
|
||||||
|
Errors []error
|
||||||
|
ErrorFormat ErrorFormatFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Error) Error() string {
|
||||||
|
fn := e.ErrorFormat
|
||||||
|
if fn == nil {
|
||||||
|
fn = ListFormatFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
return fn(e.Errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorOrNil returns an error interface if this Error represents
|
||||||
|
// a list of errors, or returns nil if the list of errors is empty. This
|
||||||
|
// function is useful at the end of accumulation to make sure that the value
|
||||||
|
// returned represents the existence of errors.
|
||||||
|
func (e *Error) ErrorOrNil() error {
|
||||||
|
if e == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if len(e.Errors) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Error) GoString() string {
|
||||||
|
return fmt.Sprintf("*%#v", *e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrappedErrors returns the list of errors that this Error is wrapping. It is
|
||||||
|
// an implementation of the errwrap.Wrapper interface so that multierror.Error
|
||||||
|
// can be used with that library.
|
||||||
|
//
|
||||||
|
// This method is not safe to be called concurrently. Unlike accessing the
|
||||||
|
// Errors field directly, this function also checks if the multierror is nil to
|
||||||
|
// prevent a null-pointer panic. It satisfies the errwrap.Wrapper interface.
|
||||||
|
func (e *Error) WrappedErrors() []error {
|
||||||
|
if e == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return e.Errors
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap returns an error from Error (or nil if there are no errors).
|
||||||
|
// This error returned will further support Unwrap to get the next error,
|
||||||
|
// etc. The order will match the order of Errors in the multierror.Error
|
||||||
|
// at the time of calling.
|
||||||
|
//
|
||||||
|
// The resulting error supports errors.As/Is/Unwrap so you can continue
|
||||||
|
// to use the stdlib errors package to introspect further.
|
||||||
|
//
|
||||||
|
// This will perform a shallow copy of the errors slice. Any errors appended
|
||||||
|
// to this error after calling Unwrap will not be available until a new
|
||||||
|
// Unwrap is called on the multierror.Error.
|
||||||
|
func (e *Error) Unwrap() error {
|
||||||
|
// If we have no errors then we do nothing
|
||||||
|
if e == nil || len(e.Errors) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have exactly one error, we can just return that directly.
|
||||||
|
if len(e.Errors) == 1 {
|
||||||
|
return e.Errors[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shallow copy the slice
|
||||||
|
errs := make([]error, len(e.Errors))
|
||||||
|
copy(errs, e.Errors)
|
||||||
|
return chain(errs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// chain implements the interfaces necessary for errors.Is/As/Unwrap to
|
||||||
|
// work in a deterministic way with multierror. A chain tracks a list of
|
||||||
|
// errors while accounting for the current represented error. This lets
|
||||||
|
// Is/As be meaningful.
|
||||||
|
//
|
||||||
|
// Unwrap returns the next error. In the cleanest form, Unwrap would return
|
||||||
|
// the wrapped error here but we can't do that if we want to properly
|
||||||
|
// get access to all the errors. Instead, users are recommended to use
|
||||||
|
// Is/As to get the correct error type out.
|
||||||
|
//
|
||||||
|
// Precondition: []error is non-empty (len > 0)
|
||||||
|
type chain []error
|
||||||
|
|
||||||
|
// Error implements the error interface
|
||||||
|
func (e chain) Error() string {
|
||||||
|
return e[0].Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap implements errors.Unwrap by returning the next error in the
|
||||||
|
// chain or nil if there are no more errors.
|
||||||
|
func (e chain) Unwrap() error {
|
||||||
|
if len(e) == 1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return e[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// As implements errors.As by attempting to map to the current value.
|
||||||
|
func (e chain) As(target interface{}) bool {
|
||||||
|
return errors.As(e[0], target)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is implements errors.Is by comparing the current value directly.
|
||||||
|
func (e chain) Is(target error) bool {
|
||||||
|
return errors.Is(e[0], target)
|
||||||
|
}
|
37
vendor/github.com/hashicorp/go-multierror/prefix.go
generated
vendored
Normal file
37
vendor/github.com/hashicorp/go-multierror/prefix.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hashicorp/errwrap"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Prefix is a helper function that will prefix some text
|
||||||
|
// to the given error. If the error is a multierror.Error, then
|
||||||
|
// it will be prefixed to each wrapped error.
|
||||||
|
//
|
||||||
|
// This is useful to use when appending multiple multierrors
|
||||||
|
// together in order to give better scoping.
|
||||||
|
func Prefix(err error, prefix string) error {
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
format := fmt.Sprintf("%s {{err}}", prefix)
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *Error:
|
||||||
|
// Typed nils can reach here, so initialize if we are nil
|
||||||
|
if err == nil {
|
||||||
|
err = new(Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap each of the errors
|
||||||
|
for i, e := range err.Errors {
|
||||||
|
err.Errors[i] = errwrap.Wrapf(format, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
return errwrap.Wrapf(format, err)
|
||||||
|
}
|
||||||
|
}
|
16
vendor/github.com/hashicorp/go-multierror/sort.go
generated
vendored
Normal file
16
vendor/github.com/hashicorp/go-multierror/sort.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package multierror
|
||||||
|
|
||||||
|
// Len implements sort.Interface function for length
|
||||||
|
func (err Error) Len() int {
|
||||||
|
return len(err.Errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap implements sort.Interface function for swapping elements
|
||||||
|
func (err Error) Swap(i, j int) {
|
||||||
|
err.Errors[i], err.Errors[j] = err.Errors[j], err.Errors[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Less implements sort.Interface function for determining order
|
||||||
|
func (err Error) Less(i, j int) bool {
|
||||||
|
return err.Errors[i].Error() < err.Errors[j].Error()
|
||||||
|
}
|
3
vendor/golang.org/x/crypto/AUTHORS
generated
vendored
Normal file
3
vendor/golang.org/x/crypto/AUTHORS
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# This source code refers to The Go Authors for copyright purposes.
|
||||||
|
# The master list of authors is in the main Go distribution,
|
||||||
|
# visible at https://tip.golang.org/AUTHORS.
|
3
vendor/golang.org/x/crypto/CONTRIBUTORS
generated
vendored
Normal file
3
vendor/golang.org/x/crypto/CONTRIBUTORS
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# This source code was written by the Go contributors.
|
||||||
|
# The master list of contributors is in the main Go distribution,
|
||||||
|
# visible at https://tip.golang.org/CONTRIBUTORS.
|
27
vendor/golang.org/x/crypto/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/crypto/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
vendor/golang.org/x/crypto/PATENTS
generated
vendored
Normal file
22
vendor/golang.org/x/crypto/PATENTS
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
Google as part of the Go project.
|
||||||
|
|
||||||
|
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||||
|
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||||
|
patent license to make, have made, use, offer to sell, sell, import,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation of Go, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by Google and acquired in
|
||||||
|
the future, licensable by Google that are necessarily infringed by this
|
||||||
|
implementation of Go. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation of Go or any code incorporated within this
|
||||||
|
implementation of Go constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation of Go
|
||||||
|
shall terminate as of the date such litigation is filed.
|
291
vendor/golang.org/x/crypto/blake2b/blake2b.go
generated
vendored
Normal file
291
vendor/golang.org/x/crypto/blake2b/blake2b.go
generated
vendored
Normal file
|
@ -0,0 +1,291 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
// Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693
|
||||||
|
// and the extendable output function (XOF) BLAKE2Xb.
|
||||||
|
//
|
||||||
|
// BLAKE2b is optimized for 64-bit platforms—including NEON-enabled ARMs—and
|
||||||
|
// produces digests of any size between 1 and 64 bytes.
|
||||||
|
// For a detailed specification of BLAKE2b see https://blake2.net/blake2.pdf
|
||||||
|
// and for BLAKE2Xb see https://blake2.net/blake2x.pdf
|
||||||
|
//
|
||||||
|
// If you aren't sure which function you need, use BLAKE2b (Sum512 or New512).
|
||||||
|
// If you need a secret-key MAC (message authentication code), use the New512
|
||||||
|
// function with a non-nil key.
|
||||||
|
//
|
||||||
|
// BLAKE2X is a construction to compute hash values larger than 64 bytes. It
|
||||||
|
// can produce hash values between 0 and 4 GiB.
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
"hash"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// The blocksize of BLAKE2b in bytes.
|
||||||
|
BlockSize = 128
|
||||||
|
// The hash size of BLAKE2b-512 in bytes.
|
||||||
|
Size = 64
|
||||||
|
// The hash size of BLAKE2b-384 in bytes.
|
||||||
|
Size384 = 48
|
||||||
|
// The hash size of BLAKE2b-256 in bytes.
|
||||||
|
Size256 = 32
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
useAVX2 bool
|
||||||
|
useAVX bool
|
||||||
|
useSSE4 bool
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errKeySize = errors.New("blake2b: invalid key size")
|
||||||
|
errHashSize = errors.New("blake2b: invalid hash size")
|
||||||
|
)
|
||||||
|
|
||||||
|
var iv = [8]uint64{
|
||||||
|
0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
|
||||||
|
0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum512 returns the BLAKE2b-512 checksum of the data.
|
||||||
|
func Sum512(data []byte) [Size]byte {
|
||||||
|
var sum [Size]byte
|
||||||
|
checkSum(&sum, Size, data)
|
||||||
|
return sum
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum384 returns the BLAKE2b-384 checksum of the data.
|
||||||
|
func Sum384(data []byte) [Size384]byte {
|
||||||
|
var sum [Size]byte
|
||||||
|
var sum384 [Size384]byte
|
||||||
|
checkSum(&sum, Size384, data)
|
||||||
|
copy(sum384[:], sum[:Size384])
|
||||||
|
return sum384
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum256 returns the BLAKE2b-256 checksum of the data.
|
||||||
|
func Sum256(data []byte) [Size256]byte {
|
||||||
|
var sum [Size]byte
|
||||||
|
var sum256 [Size256]byte
|
||||||
|
checkSum(&sum, Size256, data)
|
||||||
|
copy(sum256[:], sum[:Size256])
|
||||||
|
return sum256
|
||||||
|
}
|
||||||
|
|
||||||
|
// New512 returns a new hash.Hash computing the BLAKE2b-512 checksum. A non-nil
|
||||||
|
// key turns the hash into a MAC. The key must be between zero and 64 bytes long.
|
||||||
|
func New512(key []byte) (hash.Hash, error) { return newDigest(Size, key) }
|
||||||
|
|
||||||
|
// New384 returns a new hash.Hash computing the BLAKE2b-384 checksum. A non-nil
|
||||||
|
// key turns the hash into a MAC. The key must be between zero and 64 bytes long.
|
||||||
|
func New384(key []byte) (hash.Hash, error) { return newDigest(Size384, key) }
|
||||||
|
|
||||||
|
// New256 returns a new hash.Hash computing the BLAKE2b-256 checksum. A non-nil
|
||||||
|
// key turns the hash into a MAC. The key must be between zero and 64 bytes long.
|
||||||
|
func New256(key []byte) (hash.Hash, error) { return newDigest(Size256, key) }
|
||||||
|
|
||||||
|
// New returns a new hash.Hash computing the BLAKE2b checksum with a custom length.
|
||||||
|
// A non-nil key turns the hash into a MAC. The key must be between zero and 64 bytes long.
|
||||||
|
// The hash size can be a value between 1 and 64 but it is highly recommended to use
|
||||||
|
// values equal or greater than:
|
||||||
|
// - 32 if BLAKE2b is used as a hash function (The key is zero bytes long).
|
||||||
|
// - 16 if BLAKE2b is used as a MAC function (The key is at least 16 bytes long).
|
||||||
|
// When the key is nil, the returned hash.Hash implements BinaryMarshaler
|
||||||
|
// and BinaryUnmarshaler for state (de)serialization as documented by hash.Hash.
|
||||||
|
func New(size int, key []byte) (hash.Hash, error) { return newDigest(size, key) }
|
||||||
|
|
||||||
|
func newDigest(hashSize int, key []byte) (*digest, error) {
|
||||||
|
if hashSize < 1 || hashSize > Size {
|
||||||
|
return nil, errHashSize
|
||||||
|
}
|
||||||
|
if len(key) > Size {
|
||||||
|
return nil, errKeySize
|
||||||
|
}
|
||||||
|
d := &digest{
|
||||||
|
size: hashSize,
|
||||||
|
keyLen: len(key),
|
||||||
|
}
|
||||||
|
copy(d.key[:], key)
|
||||||
|
d.Reset()
|
||||||
|
return d, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkSum(sum *[Size]byte, hashSize int, data []byte) {
|
||||||
|
h := iv
|
||||||
|
h[0] ^= uint64(hashSize) | (1 << 16) | (1 << 24)
|
||||||
|
var c [2]uint64
|
||||||
|
|
||||||
|
if length := len(data); length > BlockSize {
|
||||||
|
n := length &^ (BlockSize - 1)
|
||||||
|
if length == n {
|
||||||
|
n -= BlockSize
|
||||||
|
}
|
||||||
|
hashBlocks(&h, &c, 0, data[:n])
|
||||||
|
data = data[n:]
|
||||||
|
}
|
||||||
|
|
||||||
|
var block [BlockSize]byte
|
||||||
|
offset := copy(block[:], data)
|
||||||
|
remaining := uint64(BlockSize - offset)
|
||||||
|
if c[0] < remaining {
|
||||||
|
c[1]--
|
||||||
|
}
|
||||||
|
c[0] -= remaining
|
||||||
|
|
||||||
|
hashBlocks(&h, &c, 0xFFFFFFFFFFFFFFFF, block[:])
|
||||||
|
|
||||||
|
for i, v := range h[:(hashSize+7)/8] {
|
||||||
|
binary.LittleEndian.PutUint64(sum[8*i:], v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type digest struct {
|
||||||
|
h [8]uint64
|
||||||
|
c [2]uint64
|
||||||
|
size int
|
||||||
|
block [BlockSize]byte
|
||||||
|
offset int
|
||||||
|
|
||||||
|
key [BlockSize]byte
|
||||||
|
keyLen int
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
magic = "b2b"
|
||||||
|
marshaledSize = len(magic) + 8*8 + 2*8 + 1 + BlockSize + 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *digest) MarshalBinary() ([]byte, error) {
|
||||||
|
if d.keyLen != 0 {
|
||||||
|
return nil, errors.New("crypto/blake2b: cannot marshal MACs")
|
||||||
|
}
|
||||||
|
b := make([]byte, 0, marshaledSize)
|
||||||
|
b = append(b, magic...)
|
||||||
|
for i := 0; i < 8; i++ {
|
||||||
|
b = appendUint64(b, d.h[i])
|
||||||
|
}
|
||||||
|
b = appendUint64(b, d.c[0])
|
||||||
|
b = appendUint64(b, d.c[1])
|
||||||
|
// Maximum value for size is 64
|
||||||
|
b = append(b, byte(d.size))
|
||||||
|
b = append(b, d.block[:]...)
|
||||||
|
b = append(b, byte(d.offset))
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *digest) UnmarshalBinary(b []byte) error {
|
||||||
|
if len(b) < len(magic) || string(b[:len(magic)]) != magic {
|
||||||
|
return errors.New("crypto/blake2b: invalid hash state identifier")
|
||||||
|
}
|
||||||
|
if len(b) != marshaledSize {
|
||||||
|
return errors.New("crypto/blake2b: invalid hash state size")
|
||||||
|
}
|
||||||
|
b = b[len(magic):]
|
||||||
|
for i := 0; i < 8; i++ {
|
||||||
|
b, d.h[i] = consumeUint64(b)
|
||||||
|
}
|
||||||
|
b, d.c[0] = consumeUint64(b)
|
||||||
|
b, d.c[1] = consumeUint64(b)
|
||||||
|
d.size = int(b[0])
|
||||||
|
b = b[1:]
|
||||||
|
copy(d.block[:], b[:BlockSize])
|
||||||
|
b = b[BlockSize:]
|
||||||
|
d.offset = int(b[0])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *digest) BlockSize() int { return BlockSize }
|
||||||
|
|
||||||
|
func (d *digest) Size() int { return d.size }
|
||||||
|
|
||||||
|
func (d *digest) Reset() {
|
||||||
|
d.h = iv
|
||||||
|
d.h[0] ^= uint64(d.size) | (uint64(d.keyLen) << 8) | (1 << 16) | (1 << 24)
|
||||||
|
d.offset, d.c[0], d.c[1] = 0, 0, 0
|
||||||
|
if d.keyLen > 0 {
|
||||||
|
d.block = d.key
|
||||||
|
d.offset = BlockSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *digest) Write(p []byte) (n int, err error) {
|
||||||
|
n = len(p)
|
||||||
|
|
||||||
|
if d.offset > 0 {
|
||||||
|
remaining := BlockSize - d.offset
|
||||||
|
if n <= remaining {
|
||||||
|
d.offset += copy(d.block[d.offset:], p)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
copy(d.block[d.offset:], p[:remaining])
|
||||||
|
hashBlocks(&d.h, &d.c, 0, d.block[:])
|
||||||
|
d.offset = 0
|
||||||
|
p = p[remaining:]
|
||||||
|
}
|
||||||
|
|
||||||
|
if length := len(p); length > BlockSize {
|
||||||
|
nn := length &^ (BlockSize - 1)
|
||||||
|
if length == nn {
|
||||||
|
nn -= BlockSize
|
||||||
|
}
|
||||||
|
hashBlocks(&d.h, &d.c, 0, p[:nn])
|
||||||
|
p = p[nn:]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(p) > 0 {
|
||||||
|
d.offset += copy(d.block[:], p)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *digest) Sum(sum []byte) []byte {
|
||||||
|
var hash [Size]byte
|
||||||
|
d.finalize(&hash)
|
||||||
|
return append(sum, hash[:d.size]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *digest) finalize(hash *[Size]byte) {
|
||||||
|
var block [BlockSize]byte
|
||||||
|
copy(block[:], d.block[:d.offset])
|
||||||
|
remaining := uint64(BlockSize - d.offset)
|
||||||
|
|
||||||
|
c := d.c
|
||||||
|
if c[0] < remaining {
|
||||||
|
c[1]--
|
||||||
|
}
|
||||||
|
c[0] -= remaining
|
||||||
|
|
||||||
|
h := d.h
|
||||||
|
hashBlocks(&h, &c, 0xFFFFFFFFFFFFFFFF, block[:])
|
||||||
|
|
||||||
|
for i, v := range h {
|
||||||
|
binary.LittleEndian.PutUint64(hash[8*i:], v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendUint64(b []byte, x uint64) []byte {
|
||||||
|
var a [8]byte
|
||||||
|
binary.BigEndian.PutUint64(a[:], x)
|
||||||
|
return append(b, a[:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendUint32(b []byte, x uint32) []byte {
|
||||||
|
var a [4]byte
|
||||||
|
binary.BigEndian.PutUint32(a[:], x)
|
||||||
|
return append(b, a[:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func consumeUint64(b []byte) ([]byte, uint64) {
|
||||||
|
x := binary.BigEndian.Uint64(b)
|
||||||
|
return b[8:], x
|
||||||
|
}
|
||||||
|
|
||||||
|
func consumeUint32(b []byte) ([]byte, uint32) {
|
||||||
|
x := binary.BigEndian.Uint32(b)
|
||||||
|
return b[4:], x
|
||||||
|
}
|
38
vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go
generated
vendored
Normal file
38
vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
//go:build go1.7 && amd64 && gc && !purego
|
||||||
|
// +build go1.7,amd64,gc,!purego
|
||||||
|
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
import "golang.org/x/sys/cpu"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
useAVX2 = cpu.X86.HasAVX2
|
||||||
|
useAVX = cpu.X86.HasAVX
|
||||||
|
useSSE4 = cpu.X86.HasSSE41
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func hashBlocksAVX(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
|
||||||
|
func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
|
||||||
|
switch {
|
||||||
|
case useAVX2:
|
||||||
|
hashBlocksAVX2(h, c, flag, blocks)
|
||||||
|
case useAVX:
|
||||||
|
hashBlocksAVX(h, c, flag, blocks)
|
||||||
|
case useSSE4:
|
||||||
|
hashBlocksSSE4(h, c, flag, blocks)
|
||||||
|
default:
|
||||||
|
hashBlocksGeneric(h, c, flag, blocks)
|
||||||
|
}
|
||||||
|
}
|
745
vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s
generated
vendored
Normal file
745
vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,745 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
//go:build go1.7 && amd64 && gc && !purego
|
||||||
|
// +build go1.7,amd64,gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
DATA ·AVX2_iv0<>+0x00(SB)/8, $0x6a09e667f3bcc908
|
||||||
|
DATA ·AVX2_iv0<>+0x08(SB)/8, $0xbb67ae8584caa73b
|
||||||
|
DATA ·AVX2_iv0<>+0x10(SB)/8, $0x3c6ef372fe94f82b
|
||||||
|
DATA ·AVX2_iv0<>+0x18(SB)/8, $0xa54ff53a5f1d36f1
|
||||||
|
GLOBL ·AVX2_iv0<>(SB), (NOPTR+RODATA), $32
|
||||||
|
|
||||||
|
DATA ·AVX2_iv1<>+0x00(SB)/8, $0x510e527fade682d1
|
||||||
|
DATA ·AVX2_iv1<>+0x08(SB)/8, $0x9b05688c2b3e6c1f
|
||||||
|
DATA ·AVX2_iv1<>+0x10(SB)/8, $0x1f83d9abfb41bd6b
|
||||||
|
DATA ·AVX2_iv1<>+0x18(SB)/8, $0x5be0cd19137e2179
|
||||||
|
GLOBL ·AVX2_iv1<>(SB), (NOPTR+RODATA), $32
|
||||||
|
|
||||||
|
DATA ·AVX2_c40<>+0x00(SB)/8, $0x0201000706050403
|
||||||
|
DATA ·AVX2_c40<>+0x08(SB)/8, $0x0a09080f0e0d0c0b
|
||||||
|
DATA ·AVX2_c40<>+0x10(SB)/8, $0x0201000706050403
|
||||||
|
DATA ·AVX2_c40<>+0x18(SB)/8, $0x0a09080f0e0d0c0b
|
||||||
|
GLOBL ·AVX2_c40<>(SB), (NOPTR+RODATA), $32
|
||||||
|
|
||||||
|
DATA ·AVX2_c48<>+0x00(SB)/8, $0x0100070605040302
|
||||||
|
DATA ·AVX2_c48<>+0x08(SB)/8, $0x09080f0e0d0c0b0a
|
||||||
|
DATA ·AVX2_c48<>+0x10(SB)/8, $0x0100070605040302
|
||||||
|
DATA ·AVX2_c48<>+0x18(SB)/8, $0x09080f0e0d0c0b0a
|
||||||
|
GLOBL ·AVX2_c48<>(SB), (NOPTR+RODATA), $32
|
||||||
|
|
||||||
|
DATA ·AVX_iv0<>+0x00(SB)/8, $0x6a09e667f3bcc908
|
||||||
|
DATA ·AVX_iv0<>+0x08(SB)/8, $0xbb67ae8584caa73b
|
||||||
|
GLOBL ·AVX_iv0<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·AVX_iv1<>+0x00(SB)/8, $0x3c6ef372fe94f82b
|
||||||
|
DATA ·AVX_iv1<>+0x08(SB)/8, $0xa54ff53a5f1d36f1
|
||||||
|
GLOBL ·AVX_iv1<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·AVX_iv2<>+0x00(SB)/8, $0x510e527fade682d1
|
||||||
|
DATA ·AVX_iv2<>+0x08(SB)/8, $0x9b05688c2b3e6c1f
|
||||||
|
GLOBL ·AVX_iv2<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·AVX_iv3<>+0x00(SB)/8, $0x1f83d9abfb41bd6b
|
||||||
|
DATA ·AVX_iv3<>+0x08(SB)/8, $0x5be0cd19137e2179
|
||||||
|
GLOBL ·AVX_iv3<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·AVX_c40<>+0x00(SB)/8, $0x0201000706050403
|
||||||
|
DATA ·AVX_c40<>+0x08(SB)/8, $0x0a09080f0e0d0c0b
|
||||||
|
GLOBL ·AVX_c40<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·AVX_c48<>+0x00(SB)/8, $0x0100070605040302
|
||||||
|
DATA ·AVX_c48<>+0x08(SB)/8, $0x09080f0e0d0c0b0a
|
||||||
|
GLOBL ·AVX_c48<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
#define VPERMQ_0x39_Y1_Y1 BYTE $0xc4; BYTE $0xe3; BYTE $0xfd; BYTE $0x00; BYTE $0xc9; BYTE $0x39
|
||||||
|
#define VPERMQ_0x93_Y1_Y1 BYTE $0xc4; BYTE $0xe3; BYTE $0xfd; BYTE $0x00; BYTE $0xc9; BYTE $0x93
|
||||||
|
#define VPERMQ_0x4E_Y2_Y2 BYTE $0xc4; BYTE $0xe3; BYTE $0xfd; BYTE $0x00; BYTE $0xd2; BYTE $0x4e
|
||||||
|
#define VPERMQ_0x93_Y3_Y3 BYTE $0xc4; BYTE $0xe3; BYTE $0xfd; BYTE $0x00; BYTE $0xdb; BYTE $0x93
|
||||||
|
#define VPERMQ_0x39_Y3_Y3 BYTE $0xc4; BYTE $0xe3; BYTE $0xfd; BYTE $0x00; BYTE $0xdb; BYTE $0x39
|
||||||
|
|
||||||
|
#define ROUND_AVX2(m0, m1, m2, m3, t, c40, c48) \
|
||||||
|
VPADDQ m0, Y0, Y0; \
|
||||||
|
VPADDQ Y1, Y0, Y0; \
|
||||||
|
VPXOR Y0, Y3, Y3; \
|
||||||
|
VPSHUFD $-79, Y3, Y3; \
|
||||||
|
VPADDQ Y3, Y2, Y2; \
|
||||||
|
VPXOR Y2, Y1, Y1; \
|
||||||
|
VPSHUFB c40, Y1, Y1; \
|
||||||
|
VPADDQ m1, Y0, Y0; \
|
||||||
|
VPADDQ Y1, Y0, Y0; \
|
||||||
|
VPXOR Y0, Y3, Y3; \
|
||||||
|
VPSHUFB c48, Y3, Y3; \
|
||||||
|
VPADDQ Y3, Y2, Y2; \
|
||||||
|
VPXOR Y2, Y1, Y1; \
|
||||||
|
VPADDQ Y1, Y1, t; \
|
||||||
|
VPSRLQ $63, Y1, Y1; \
|
||||||
|
VPXOR t, Y1, Y1; \
|
||||||
|
VPERMQ_0x39_Y1_Y1; \
|
||||||
|
VPERMQ_0x4E_Y2_Y2; \
|
||||||
|
VPERMQ_0x93_Y3_Y3; \
|
||||||
|
VPADDQ m2, Y0, Y0; \
|
||||||
|
VPADDQ Y1, Y0, Y0; \
|
||||||
|
VPXOR Y0, Y3, Y3; \
|
||||||
|
VPSHUFD $-79, Y3, Y3; \
|
||||||
|
VPADDQ Y3, Y2, Y2; \
|
||||||
|
VPXOR Y2, Y1, Y1; \
|
||||||
|
VPSHUFB c40, Y1, Y1; \
|
||||||
|
VPADDQ m3, Y0, Y0; \
|
||||||
|
VPADDQ Y1, Y0, Y0; \
|
||||||
|
VPXOR Y0, Y3, Y3; \
|
||||||
|
VPSHUFB c48, Y3, Y3; \
|
||||||
|
VPADDQ Y3, Y2, Y2; \
|
||||||
|
VPXOR Y2, Y1, Y1; \
|
||||||
|
VPADDQ Y1, Y1, t; \
|
||||||
|
VPSRLQ $63, Y1, Y1; \
|
||||||
|
VPXOR t, Y1, Y1; \
|
||||||
|
VPERMQ_0x39_Y3_Y3; \
|
||||||
|
VPERMQ_0x4E_Y2_Y2; \
|
||||||
|
VPERMQ_0x93_Y1_Y1
|
||||||
|
|
||||||
|
#define VMOVQ_SI_X11_0 BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x1E
|
||||||
|
#define VMOVQ_SI_X12_0 BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x26
|
||||||
|
#define VMOVQ_SI_X13_0 BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x2E
|
||||||
|
#define VMOVQ_SI_X14_0 BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x36
|
||||||
|
#define VMOVQ_SI_X15_0 BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x3E
|
||||||
|
|
||||||
|
#define VMOVQ_SI_X11(n) BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x5E; BYTE $n
|
||||||
|
#define VMOVQ_SI_X12(n) BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x66; BYTE $n
|
||||||
|
#define VMOVQ_SI_X13(n) BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x6E; BYTE $n
|
||||||
|
#define VMOVQ_SI_X14(n) BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x76; BYTE $n
|
||||||
|
#define VMOVQ_SI_X15(n) BYTE $0xC5; BYTE $0x7A; BYTE $0x7E; BYTE $0x7E; BYTE $n
|
||||||
|
|
||||||
|
#define VPINSRQ_1_SI_X11_0 BYTE $0xC4; BYTE $0x63; BYTE $0xA1; BYTE $0x22; BYTE $0x1E; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X12_0 BYTE $0xC4; BYTE $0x63; BYTE $0x99; BYTE $0x22; BYTE $0x26; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X13_0 BYTE $0xC4; BYTE $0x63; BYTE $0x91; BYTE $0x22; BYTE $0x2E; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X14_0 BYTE $0xC4; BYTE $0x63; BYTE $0x89; BYTE $0x22; BYTE $0x36; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X15_0 BYTE $0xC4; BYTE $0x63; BYTE $0x81; BYTE $0x22; BYTE $0x3E; BYTE $0x01
|
||||||
|
|
||||||
|
#define VPINSRQ_1_SI_X11(n) BYTE $0xC4; BYTE $0x63; BYTE $0xA1; BYTE $0x22; BYTE $0x5E; BYTE $n; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X12(n) BYTE $0xC4; BYTE $0x63; BYTE $0x99; BYTE $0x22; BYTE $0x66; BYTE $n; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X13(n) BYTE $0xC4; BYTE $0x63; BYTE $0x91; BYTE $0x22; BYTE $0x6E; BYTE $n; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X14(n) BYTE $0xC4; BYTE $0x63; BYTE $0x89; BYTE $0x22; BYTE $0x76; BYTE $n; BYTE $0x01
|
||||||
|
#define VPINSRQ_1_SI_X15(n) BYTE $0xC4; BYTE $0x63; BYTE $0x81; BYTE $0x22; BYTE $0x7E; BYTE $n; BYTE $0x01
|
||||||
|
|
||||||
|
#define VMOVQ_R8_X15 BYTE $0xC4; BYTE $0x41; BYTE $0xF9; BYTE $0x6E; BYTE $0xF8
|
||||||
|
#define VPINSRQ_1_R9_X15 BYTE $0xC4; BYTE $0x43; BYTE $0x81; BYTE $0x22; BYTE $0xF9; BYTE $0x01
|
||||||
|
|
||||||
|
// load msg: Y12 = (i0, i1, i2, i3)
|
||||||
|
// i0, i1, i2, i3 must not be 0
|
||||||
|
#define LOAD_MSG_AVX2_Y12(i0, i1, i2, i3) \
|
||||||
|
VMOVQ_SI_X12(i0*8); \
|
||||||
|
VMOVQ_SI_X11(i2*8); \
|
||||||
|
VPINSRQ_1_SI_X12(i1*8); \
|
||||||
|
VPINSRQ_1_SI_X11(i3*8); \
|
||||||
|
VINSERTI128 $1, X11, Y12, Y12
|
||||||
|
|
||||||
|
// load msg: Y13 = (i0, i1, i2, i3)
|
||||||
|
// i0, i1, i2, i3 must not be 0
|
||||||
|
#define LOAD_MSG_AVX2_Y13(i0, i1, i2, i3) \
|
||||||
|
VMOVQ_SI_X13(i0*8); \
|
||||||
|
VMOVQ_SI_X11(i2*8); \
|
||||||
|
VPINSRQ_1_SI_X13(i1*8); \
|
||||||
|
VPINSRQ_1_SI_X11(i3*8); \
|
||||||
|
VINSERTI128 $1, X11, Y13, Y13
|
||||||
|
|
||||||
|
// load msg: Y14 = (i0, i1, i2, i3)
|
||||||
|
// i0, i1, i2, i3 must not be 0
|
||||||
|
#define LOAD_MSG_AVX2_Y14(i0, i1, i2, i3) \
|
||||||
|
VMOVQ_SI_X14(i0*8); \
|
||||||
|
VMOVQ_SI_X11(i2*8); \
|
||||||
|
VPINSRQ_1_SI_X14(i1*8); \
|
||||||
|
VPINSRQ_1_SI_X11(i3*8); \
|
||||||
|
VINSERTI128 $1, X11, Y14, Y14
|
||||||
|
|
||||||
|
// load msg: Y15 = (i0, i1, i2, i3)
|
||||||
|
// i0, i1, i2, i3 must not be 0
|
||||||
|
#define LOAD_MSG_AVX2_Y15(i0, i1, i2, i3) \
|
||||||
|
VMOVQ_SI_X15(i0*8); \
|
||||||
|
VMOVQ_SI_X11(i2*8); \
|
||||||
|
VPINSRQ_1_SI_X15(i1*8); \
|
||||||
|
VPINSRQ_1_SI_X11(i3*8); \
|
||||||
|
VINSERTI128 $1, X11, Y15, Y15
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_0_2_4_6_1_3_5_7_8_10_12_14_9_11_13_15() \
|
||||||
|
VMOVQ_SI_X12_0; \
|
||||||
|
VMOVQ_SI_X11(4*8); \
|
||||||
|
VPINSRQ_1_SI_X12(2*8); \
|
||||||
|
VPINSRQ_1_SI_X11(6*8); \
|
||||||
|
VINSERTI128 $1, X11, Y12, Y12; \
|
||||||
|
LOAD_MSG_AVX2_Y13(1, 3, 5, 7); \
|
||||||
|
LOAD_MSG_AVX2_Y14(8, 10, 12, 14); \
|
||||||
|
LOAD_MSG_AVX2_Y15(9, 11, 13, 15)
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_14_4_9_13_10_8_15_6_1_0_11_5_12_2_7_3() \
|
||||||
|
LOAD_MSG_AVX2_Y12(14, 4, 9, 13); \
|
||||||
|
LOAD_MSG_AVX2_Y13(10, 8, 15, 6); \
|
||||||
|
VMOVQ_SI_X11(11*8); \
|
||||||
|
VPSHUFD $0x4E, 0*8(SI), X14; \
|
||||||
|
VPINSRQ_1_SI_X11(5*8); \
|
||||||
|
VINSERTI128 $1, X11, Y14, Y14; \
|
||||||
|
LOAD_MSG_AVX2_Y15(12, 2, 7, 3)
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_11_12_5_15_8_0_2_13_10_3_7_9_14_6_1_4() \
|
||||||
|
VMOVQ_SI_X11(5*8); \
|
||||||
|
VMOVDQU 11*8(SI), X12; \
|
||||||
|
VPINSRQ_1_SI_X11(15*8); \
|
||||||
|
VINSERTI128 $1, X11, Y12, Y12; \
|
||||||
|
VMOVQ_SI_X13(8*8); \
|
||||||
|
VMOVQ_SI_X11(2*8); \
|
||||||
|
VPINSRQ_1_SI_X13_0; \
|
||||||
|
VPINSRQ_1_SI_X11(13*8); \
|
||||||
|
VINSERTI128 $1, X11, Y13, Y13; \
|
||||||
|
LOAD_MSG_AVX2_Y14(10, 3, 7, 9); \
|
||||||
|
LOAD_MSG_AVX2_Y15(14, 6, 1, 4)
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_7_3_13_11_9_1_12_14_2_5_4_15_6_10_0_8() \
|
||||||
|
LOAD_MSG_AVX2_Y12(7, 3, 13, 11); \
|
||||||
|
LOAD_MSG_AVX2_Y13(9, 1, 12, 14); \
|
||||||
|
LOAD_MSG_AVX2_Y14(2, 5, 4, 15); \
|
||||||
|
VMOVQ_SI_X15(6*8); \
|
||||||
|
VMOVQ_SI_X11_0; \
|
||||||
|
VPINSRQ_1_SI_X15(10*8); \
|
||||||
|
VPINSRQ_1_SI_X11(8*8); \
|
||||||
|
VINSERTI128 $1, X11, Y15, Y15
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_9_5_2_10_0_7_4_15_14_11_6_3_1_12_8_13() \
|
||||||
|
LOAD_MSG_AVX2_Y12(9, 5, 2, 10); \
|
||||||
|
VMOVQ_SI_X13_0; \
|
||||||
|
VMOVQ_SI_X11(4*8); \
|
||||||
|
VPINSRQ_1_SI_X13(7*8); \
|
||||||
|
VPINSRQ_1_SI_X11(15*8); \
|
||||||
|
VINSERTI128 $1, X11, Y13, Y13; \
|
||||||
|
LOAD_MSG_AVX2_Y14(14, 11, 6, 3); \
|
||||||
|
LOAD_MSG_AVX2_Y15(1, 12, 8, 13)
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_2_6_0_8_12_10_11_3_4_7_15_1_13_5_14_9() \
|
||||||
|
VMOVQ_SI_X12(2*8); \
|
||||||
|
VMOVQ_SI_X11_0; \
|
||||||
|
VPINSRQ_1_SI_X12(6*8); \
|
||||||
|
VPINSRQ_1_SI_X11(8*8); \
|
||||||
|
VINSERTI128 $1, X11, Y12, Y12; \
|
||||||
|
LOAD_MSG_AVX2_Y13(12, 10, 11, 3); \
|
||||||
|
LOAD_MSG_AVX2_Y14(4, 7, 15, 1); \
|
||||||
|
LOAD_MSG_AVX2_Y15(13, 5, 14, 9)
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_12_1_14_4_5_15_13_10_0_6_9_8_7_3_2_11() \
|
||||||
|
LOAD_MSG_AVX2_Y12(12, 1, 14, 4); \
|
||||||
|
LOAD_MSG_AVX2_Y13(5, 15, 13, 10); \
|
||||||
|
VMOVQ_SI_X14_0; \
|
||||||
|
VPSHUFD $0x4E, 8*8(SI), X11; \
|
||||||
|
VPINSRQ_1_SI_X14(6*8); \
|
||||||
|
VINSERTI128 $1, X11, Y14, Y14; \
|
||||||
|
LOAD_MSG_AVX2_Y15(7, 3, 2, 11)
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_13_7_12_3_11_14_1_9_5_15_8_2_0_4_6_10() \
|
||||||
|
LOAD_MSG_AVX2_Y12(13, 7, 12, 3); \
|
||||||
|
LOAD_MSG_AVX2_Y13(11, 14, 1, 9); \
|
||||||
|
LOAD_MSG_AVX2_Y14(5, 15, 8, 2); \
|
||||||
|
VMOVQ_SI_X15_0; \
|
||||||
|
VMOVQ_SI_X11(6*8); \
|
||||||
|
VPINSRQ_1_SI_X15(4*8); \
|
||||||
|
VPINSRQ_1_SI_X11(10*8); \
|
||||||
|
VINSERTI128 $1, X11, Y15, Y15
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_6_14_11_0_15_9_3_8_12_13_1_10_2_7_4_5() \
|
||||||
|
VMOVQ_SI_X12(6*8); \
|
||||||
|
VMOVQ_SI_X11(11*8); \
|
||||||
|
VPINSRQ_1_SI_X12(14*8); \
|
||||||
|
VPINSRQ_1_SI_X11_0; \
|
||||||
|
VINSERTI128 $1, X11, Y12, Y12; \
|
||||||
|
LOAD_MSG_AVX2_Y13(15, 9, 3, 8); \
|
||||||
|
VMOVQ_SI_X11(1*8); \
|
||||||
|
VMOVDQU 12*8(SI), X14; \
|
||||||
|
VPINSRQ_1_SI_X11(10*8); \
|
||||||
|
VINSERTI128 $1, X11, Y14, Y14; \
|
||||||
|
VMOVQ_SI_X15(2*8); \
|
||||||
|
VMOVDQU 4*8(SI), X11; \
|
||||||
|
VPINSRQ_1_SI_X15(7*8); \
|
||||||
|
VINSERTI128 $1, X11, Y15, Y15
|
||||||
|
|
||||||
|
#define LOAD_MSG_AVX2_10_8_7_1_2_4_6_5_15_9_3_13_11_14_12_0() \
|
||||||
|
LOAD_MSG_AVX2_Y12(10, 8, 7, 1); \
|
||||||
|
VMOVQ_SI_X13(2*8); \
|
||||||
|
VPSHUFD $0x4E, 5*8(SI), X11; \
|
||||||
|
VPINSRQ_1_SI_X13(4*8); \
|
||||||
|
VINSERTI128 $1, X11, Y13, Y13; \
|
||||||
|
LOAD_MSG_AVX2_Y14(15, 9, 3, 13); \
|
||||||
|
VMOVQ_SI_X15(11*8); \
|
||||||
|
VMOVQ_SI_X11(12*8); \
|
||||||
|
VPINSRQ_1_SI_X15(14*8); \
|
||||||
|
VPINSRQ_1_SI_X11_0; \
|
||||||
|
VINSERTI128 $1, X11, Y15, Y15
|
||||||
|
|
||||||
|
// func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
TEXT ·hashBlocksAVX2(SB), 4, $320-48 // frame size = 288 + 32 byte alignment
|
||||||
|
MOVQ h+0(FP), AX
|
||||||
|
MOVQ c+8(FP), BX
|
||||||
|
MOVQ flag+16(FP), CX
|
||||||
|
MOVQ blocks_base+24(FP), SI
|
||||||
|
MOVQ blocks_len+32(FP), DI
|
||||||
|
|
||||||
|
MOVQ SP, DX
|
||||||
|
ADDQ $31, DX
|
||||||
|
ANDQ $~31, DX
|
||||||
|
|
||||||
|
MOVQ CX, 16(DX)
|
||||||
|
XORQ CX, CX
|
||||||
|
MOVQ CX, 24(DX)
|
||||||
|
|
||||||
|
VMOVDQU ·AVX2_c40<>(SB), Y4
|
||||||
|
VMOVDQU ·AVX2_c48<>(SB), Y5
|
||||||
|
|
||||||
|
VMOVDQU 0(AX), Y8
|
||||||
|
VMOVDQU 32(AX), Y9
|
||||||
|
VMOVDQU ·AVX2_iv0<>(SB), Y6
|
||||||
|
VMOVDQU ·AVX2_iv1<>(SB), Y7
|
||||||
|
|
||||||
|
MOVQ 0(BX), R8
|
||||||
|
MOVQ 8(BX), R9
|
||||||
|
MOVQ R9, 8(DX)
|
||||||
|
|
||||||
|
loop:
|
||||||
|
ADDQ $128, R8
|
||||||
|
MOVQ R8, 0(DX)
|
||||||
|
CMPQ R8, $128
|
||||||
|
JGE noinc
|
||||||
|
INCQ R9
|
||||||
|
MOVQ R9, 8(DX)
|
||||||
|
|
||||||
|
noinc:
|
||||||
|
VMOVDQA Y8, Y0
|
||||||
|
VMOVDQA Y9, Y1
|
||||||
|
VMOVDQA Y6, Y2
|
||||||
|
VPXOR 0(DX), Y7, Y3
|
||||||
|
|
||||||
|
LOAD_MSG_AVX2_0_2_4_6_1_3_5_7_8_10_12_14_9_11_13_15()
|
||||||
|
VMOVDQA Y12, 32(DX)
|
||||||
|
VMOVDQA Y13, 64(DX)
|
||||||
|
VMOVDQA Y14, 96(DX)
|
||||||
|
VMOVDQA Y15, 128(DX)
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_14_4_9_13_10_8_15_6_1_0_11_5_12_2_7_3()
|
||||||
|
VMOVDQA Y12, 160(DX)
|
||||||
|
VMOVDQA Y13, 192(DX)
|
||||||
|
VMOVDQA Y14, 224(DX)
|
||||||
|
VMOVDQA Y15, 256(DX)
|
||||||
|
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_11_12_5_15_8_0_2_13_10_3_7_9_14_6_1_4()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_7_3_13_11_9_1_12_14_2_5_4_15_6_10_0_8()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_9_5_2_10_0_7_4_15_14_11_6_3_1_12_8_13()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_2_6_0_8_12_10_11_3_4_7_15_1_13_5_14_9()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_12_1_14_4_5_15_13_10_0_6_9_8_7_3_2_11()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_13_7_12_3_11_14_1_9_5_15_8_2_0_4_6_10()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_6_14_11_0_15_9_3_8_12_13_1_10_2_7_4_5()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
LOAD_MSG_AVX2_10_8_7_1_2_4_6_5_15_9_3_13_11_14_12_0()
|
||||||
|
ROUND_AVX2(Y12, Y13, Y14, Y15, Y10, Y4, Y5)
|
||||||
|
|
||||||
|
ROUND_AVX2(32(DX), 64(DX), 96(DX), 128(DX), Y10, Y4, Y5)
|
||||||
|
ROUND_AVX2(160(DX), 192(DX), 224(DX), 256(DX), Y10, Y4, Y5)
|
||||||
|
|
||||||
|
VPXOR Y0, Y8, Y8
|
||||||
|
VPXOR Y1, Y9, Y9
|
||||||
|
VPXOR Y2, Y8, Y8
|
||||||
|
VPXOR Y3, Y9, Y9
|
||||||
|
|
||||||
|
LEAQ 128(SI), SI
|
||||||
|
SUBQ $128, DI
|
||||||
|
JNE loop
|
||||||
|
|
||||||
|
MOVQ R8, 0(BX)
|
||||||
|
MOVQ R9, 8(BX)
|
||||||
|
|
||||||
|
VMOVDQU Y8, 0(AX)
|
||||||
|
VMOVDQU Y9, 32(AX)
|
||||||
|
VZEROUPPER
|
||||||
|
|
||||||
|
RET
|
||||||
|
|
||||||
|
#define VPUNPCKLQDQ_X2_X2_X15 BYTE $0xC5; BYTE $0x69; BYTE $0x6C; BYTE $0xFA
|
||||||
|
#define VPUNPCKLQDQ_X3_X3_X15 BYTE $0xC5; BYTE $0x61; BYTE $0x6C; BYTE $0xFB
|
||||||
|
#define VPUNPCKLQDQ_X7_X7_X15 BYTE $0xC5; BYTE $0x41; BYTE $0x6C; BYTE $0xFF
|
||||||
|
#define VPUNPCKLQDQ_X13_X13_X15 BYTE $0xC4; BYTE $0x41; BYTE $0x11; BYTE $0x6C; BYTE $0xFD
|
||||||
|
#define VPUNPCKLQDQ_X14_X14_X15 BYTE $0xC4; BYTE $0x41; BYTE $0x09; BYTE $0x6C; BYTE $0xFE
|
||||||
|
|
||||||
|
#define VPUNPCKHQDQ_X15_X2_X2 BYTE $0xC4; BYTE $0xC1; BYTE $0x69; BYTE $0x6D; BYTE $0xD7
|
||||||
|
#define VPUNPCKHQDQ_X15_X3_X3 BYTE $0xC4; BYTE $0xC1; BYTE $0x61; BYTE $0x6D; BYTE $0xDF
|
||||||
|
#define VPUNPCKHQDQ_X15_X6_X6 BYTE $0xC4; BYTE $0xC1; BYTE $0x49; BYTE $0x6D; BYTE $0xF7
|
||||||
|
#define VPUNPCKHQDQ_X15_X7_X7 BYTE $0xC4; BYTE $0xC1; BYTE $0x41; BYTE $0x6D; BYTE $0xFF
|
||||||
|
#define VPUNPCKHQDQ_X15_X3_X2 BYTE $0xC4; BYTE $0xC1; BYTE $0x61; BYTE $0x6D; BYTE $0xD7
|
||||||
|
#define VPUNPCKHQDQ_X15_X7_X6 BYTE $0xC4; BYTE $0xC1; BYTE $0x41; BYTE $0x6D; BYTE $0xF7
|
||||||
|
#define VPUNPCKHQDQ_X15_X13_X3 BYTE $0xC4; BYTE $0xC1; BYTE $0x11; BYTE $0x6D; BYTE $0xDF
|
||||||
|
#define VPUNPCKHQDQ_X15_X13_X7 BYTE $0xC4; BYTE $0xC1; BYTE $0x11; BYTE $0x6D; BYTE $0xFF
|
||||||
|
|
||||||
|
#define SHUFFLE_AVX() \
|
||||||
|
VMOVDQA X6, X13; \
|
||||||
|
VMOVDQA X2, X14; \
|
||||||
|
VMOVDQA X4, X6; \
|
||||||
|
VPUNPCKLQDQ_X13_X13_X15; \
|
||||||
|
VMOVDQA X5, X4; \
|
||||||
|
VMOVDQA X6, X5; \
|
||||||
|
VPUNPCKHQDQ_X15_X7_X6; \
|
||||||
|
VPUNPCKLQDQ_X7_X7_X15; \
|
||||||
|
VPUNPCKHQDQ_X15_X13_X7; \
|
||||||
|
VPUNPCKLQDQ_X3_X3_X15; \
|
||||||
|
VPUNPCKHQDQ_X15_X2_X2; \
|
||||||
|
VPUNPCKLQDQ_X14_X14_X15; \
|
||||||
|
VPUNPCKHQDQ_X15_X3_X3; \
|
||||||
|
|
||||||
|
#define SHUFFLE_AVX_INV() \
|
||||||
|
VMOVDQA X2, X13; \
|
||||||
|
VMOVDQA X4, X14; \
|
||||||
|
VPUNPCKLQDQ_X2_X2_X15; \
|
||||||
|
VMOVDQA X5, X4; \
|
||||||
|
VPUNPCKHQDQ_X15_X3_X2; \
|
||||||
|
VMOVDQA X14, X5; \
|
||||||
|
VPUNPCKLQDQ_X3_X3_X15; \
|
||||||
|
VMOVDQA X6, X14; \
|
||||||
|
VPUNPCKHQDQ_X15_X13_X3; \
|
||||||
|
VPUNPCKLQDQ_X7_X7_X15; \
|
||||||
|
VPUNPCKHQDQ_X15_X6_X6; \
|
||||||
|
VPUNPCKLQDQ_X14_X14_X15; \
|
||||||
|
VPUNPCKHQDQ_X15_X7_X7; \
|
||||||
|
|
||||||
|
#define HALF_ROUND_AVX(v0, v1, v2, v3, v4, v5, v6, v7, m0, m1, m2, m3, t0, c40, c48) \
|
||||||
|
VPADDQ m0, v0, v0; \
|
||||||
|
VPADDQ v2, v0, v0; \
|
||||||
|
VPADDQ m1, v1, v1; \
|
||||||
|
VPADDQ v3, v1, v1; \
|
||||||
|
VPXOR v0, v6, v6; \
|
||||||
|
VPXOR v1, v7, v7; \
|
||||||
|
VPSHUFD $-79, v6, v6; \
|
||||||
|
VPSHUFD $-79, v7, v7; \
|
||||||
|
VPADDQ v6, v4, v4; \
|
||||||
|
VPADDQ v7, v5, v5; \
|
||||||
|
VPXOR v4, v2, v2; \
|
||||||
|
VPXOR v5, v3, v3; \
|
||||||
|
VPSHUFB c40, v2, v2; \
|
||||||
|
VPSHUFB c40, v3, v3; \
|
||||||
|
VPADDQ m2, v0, v0; \
|
||||||
|
VPADDQ v2, v0, v0; \
|
||||||
|
VPADDQ m3, v1, v1; \
|
||||||
|
VPADDQ v3, v1, v1; \
|
||||||
|
VPXOR v0, v6, v6; \
|
||||||
|
VPXOR v1, v7, v7; \
|
||||||
|
VPSHUFB c48, v6, v6; \
|
||||||
|
VPSHUFB c48, v7, v7; \
|
||||||
|
VPADDQ v6, v4, v4; \
|
||||||
|
VPADDQ v7, v5, v5; \
|
||||||
|
VPXOR v4, v2, v2; \
|
||||||
|
VPXOR v5, v3, v3; \
|
||||||
|
VPADDQ v2, v2, t0; \
|
||||||
|
VPSRLQ $63, v2, v2; \
|
||||||
|
VPXOR t0, v2, v2; \
|
||||||
|
VPADDQ v3, v3, t0; \
|
||||||
|
VPSRLQ $63, v3, v3; \
|
||||||
|
VPXOR t0, v3, v3
|
||||||
|
|
||||||
|
// load msg: X12 = (i0, i1), X13 = (i2, i3), X14 = (i4, i5), X15 = (i6, i7)
|
||||||
|
// i0, i1, i2, i3, i4, i5, i6, i7 must not be 0
|
||||||
|
#define LOAD_MSG_AVX(i0, i1, i2, i3, i4, i5, i6, i7) \
|
||||||
|
VMOVQ_SI_X12(i0*8); \
|
||||||
|
VMOVQ_SI_X13(i2*8); \
|
||||||
|
VMOVQ_SI_X14(i4*8); \
|
||||||
|
VMOVQ_SI_X15(i6*8); \
|
||||||
|
VPINSRQ_1_SI_X12(i1*8); \
|
||||||
|
VPINSRQ_1_SI_X13(i3*8); \
|
||||||
|
VPINSRQ_1_SI_X14(i5*8); \
|
||||||
|
VPINSRQ_1_SI_X15(i7*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (0, 2), X13 = (4, 6), X14 = (1, 3), X15 = (5, 7)
|
||||||
|
#define LOAD_MSG_AVX_0_2_4_6_1_3_5_7() \
|
||||||
|
VMOVQ_SI_X12_0; \
|
||||||
|
VMOVQ_SI_X13(4*8); \
|
||||||
|
VMOVQ_SI_X14(1*8); \
|
||||||
|
VMOVQ_SI_X15(5*8); \
|
||||||
|
VPINSRQ_1_SI_X12(2*8); \
|
||||||
|
VPINSRQ_1_SI_X13(6*8); \
|
||||||
|
VPINSRQ_1_SI_X14(3*8); \
|
||||||
|
VPINSRQ_1_SI_X15(7*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (1, 0), X13 = (11, 5), X14 = (12, 2), X15 = (7, 3)
|
||||||
|
#define LOAD_MSG_AVX_1_0_11_5_12_2_7_3() \
|
||||||
|
VPSHUFD $0x4E, 0*8(SI), X12; \
|
||||||
|
VMOVQ_SI_X13(11*8); \
|
||||||
|
VMOVQ_SI_X14(12*8); \
|
||||||
|
VMOVQ_SI_X15(7*8); \
|
||||||
|
VPINSRQ_1_SI_X13(5*8); \
|
||||||
|
VPINSRQ_1_SI_X14(2*8); \
|
||||||
|
VPINSRQ_1_SI_X15(3*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (11, 12), X13 = (5, 15), X14 = (8, 0), X15 = (2, 13)
|
||||||
|
#define LOAD_MSG_AVX_11_12_5_15_8_0_2_13() \
|
||||||
|
VMOVDQU 11*8(SI), X12; \
|
||||||
|
VMOVQ_SI_X13(5*8); \
|
||||||
|
VMOVQ_SI_X14(8*8); \
|
||||||
|
VMOVQ_SI_X15(2*8); \
|
||||||
|
VPINSRQ_1_SI_X13(15*8); \
|
||||||
|
VPINSRQ_1_SI_X14_0; \
|
||||||
|
VPINSRQ_1_SI_X15(13*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (2, 5), X13 = (4, 15), X14 = (6, 10), X15 = (0, 8)
|
||||||
|
#define LOAD_MSG_AVX_2_5_4_15_6_10_0_8() \
|
||||||
|
VMOVQ_SI_X12(2*8); \
|
||||||
|
VMOVQ_SI_X13(4*8); \
|
||||||
|
VMOVQ_SI_X14(6*8); \
|
||||||
|
VMOVQ_SI_X15_0; \
|
||||||
|
VPINSRQ_1_SI_X12(5*8); \
|
||||||
|
VPINSRQ_1_SI_X13(15*8); \
|
||||||
|
VPINSRQ_1_SI_X14(10*8); \
|
||||||
|
VPINSRQ_1_SI_X15(8*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (9, 5), X13 = (2, 10), X14 = (0, 7), X15 = (4, 15)
|
||||||
|
#define LOAD_MSG_AVX_9_5_2_10_0_7_4_15() \
|
||||||
|
VMOVQ_SI_X12(9*8); \
|
||||||
|
VMOVQ_SI_X13(2*8); \
|
||||||
|
VMOVQ_SI_X14_0; \
|
||||||
|
VMOVQ_SI_X15(4*8); \
|
||||||
|
VPINSRQ_1_SI_X12(5*8); \
|
||||||
|
VPINSRQ_1_SI_X13(10*8); \
|
||||||
|
VPINSRQ_1_SI_X14(7*8); \
|
||||||
|
VPINSRQ_1_SI_X15(15*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (2, 6), X13 = (0, 8), X14 = (12, 10), X15 = (11, 3)
|
||||||
|
#define LOAD_MSG_AVX_2_6_0_8_12_10_11_3() \
|
||||||
|
VMOVQ_SI_X12(2*8); \
|
||||||
|
VMOVQ_SI_X13_0; \
|
||||||
|
VMOVQ_SI_X14(12*8); \
|
||||||
|
VMOVQ_SI_X15(11*8); \
|
||||||
|
VPINSRQ_1_SI_X12(6*8); \
|
||||||
|
VPINSRQ_1_SI_X13(8*8); \
|
||||||
|
VPINSRQ_1_SI_X14(10*8); \
|
||||||
|
VPINSRQ_1_SI_X15(3*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (0, 6), X13 = (9, 8), X14 = (7, 3), X15 = (2, 11)
|
||||||
|
#define LOAD_MSG_AVX_0_6_9_8_7_3_2_11() \
|
||||||
|
MOVQ 0*8(SI), X12; \
|
||||||
|
VPSHUFD $0x4E, 8*8(SI), X13; \
|
||||||
|
MOVQ 7*8(SI), X14; \
|
||||||
|
MOVQ 2*8(SI), X15; \
|
||||||
|
VPINSRQ_1_SI_X12(6*8); \
|
||||||
|
VPINSRQ_1_SI_X14(3*8); \
|
||||||
|
VPINSRQ_1_SI_X15(11*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (6, 14), X13 = (11, 0), X14 = (15, 9), X15 = (3, 8)
|
||||||
|
#define LOAD_MSG_AVX_6_14_11_0_15_9_3_8() \
|
||||||
|
MOVQ 6*8(SI), X12; \
|
||||||
|
MOVQ 11*8(SI), X13; \
|
||||||
|
MOVQ 15*8(SI), X14; \
|
||||||
|
MOVQ 3*8(SI), X15; \
|
||||||
|
VPINSRQ_1_SI_X12(14*8); \
|
||||||
|
VPINSRQ_1_SI_X13_0; \
|
||||||
|
VPINSRQ_1_SI_X14(9*8); \
|
||||||
|
VPINSRQ_1_SI_X15(8*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (5, 15), X13 = (8, 2), X14 = (0, 4), X15 = (6, 10)
|
||||||
|
#define LOAD_MSG_AVX_5_15_8_2_0_4_6_10() \
|
||||||
|
MOVQ 5*8(SI), X12; \
|
||||||
|
MOVQ 8*8(SI), X13; \
|
||||||
|
MOVQ 0*8(SI), X14; \
|
||||||
|
MOVQ 6*8(SI), X15; \
|
||||||
|
VPINSRQ_1_SI_X12(15*8); \
|
||||||
|
VPINSRQ_1_SI_X13(2*8); \
|
||||||
|
VPINSRQ_1_SI_X14(4*8); \
|
||||||
|
VPINSRQ_1_SI_X15(10*8)
|
||||||
|
|
||||||
|
// load msg: X12 = (12, 13), X13 = (1, 10), X14 = (2, 7), X15 = (4, 5)
|
||||||
|
#define LOAD_MSG_AVX_12_13_1_10_2_7_4_5() \
|
||||||
|
VMOVDQU 12*8(SI), X12; \
|
||||||
|
MOVQ 1*8(SI), X13; \
|
||||||
|
MOVQ 2*8(SI), X14; \
|
||||||
|
VPINSRQ_1_SI_X13(10*8); \
|
||||||
|
VPINSRQ_1_SI_X14(7*8); \
|
||||||
|
VMOVDQU 4*8(SI), X15
|
||||||
|
|
||||||
|
// load msg: X12 = (15, 9), X13 = (3, 13), X14 = (11, 14), X15 = (12, 0)
|
||||||
|
#define LOAD_MSG_AVX_15_9_3_13_11_14_12_0() \
|
||||||
|
MOVQ 15*8(SI), X12; \
|
||||||
|
MOVQ 3*8(SI), X13; \
|
||||||
|
MOVQ 11*8(SI), X14; \
|
||||||
|
MOVQ 12*8(SI), X15; \
|
||||||
|
VPINSRQ_1_SI_X12(9*8); \
|
||||||
|
VPINSRQ_1_SI_X13(13*8); \
|
||||||
|
VPINSRQ_1_SI_X14(14*8); \
|
||||||
|
VPINSRQ_1_SI_X15_0
|
||||||
|
|
||||||
|
// func hashBlocksAVX(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
TEXT ·hashBlocksAVX(SB), 4, $288-48 // frame size = 272 + 16 byte alignment
|
||||||
|
MOVQ h+0(FP), AX
|
||||||
|
MOVQ c+8(FP), BX
|
||||||
|
MOVQ flag+16(FP), CX
|
||||||
|
MOVQ blocks_base+24(FP), SI
|
||||||
|
MOVQ blocks_len+32(FP), DI
|
||||||
|
|
||||||
|
MOVQ SP, R10
|
||||||
|
ADDQ $15, R10
|
||||||
|
ANDQ $~15, R10
|
||||||
|
|
||||||
|
VMOVDQU ·AVX_c40<>(SB), X0
|
||||||
|
VMOVDQU ·AVX_c48<>(SB), X1
|
||||||
|
VMOVDQA X0, X8
|
||||||
|
VMOVDQA X1, X9
|
||||||
|
|
||||||
|
VMOVDQU ·AVX_iv3<>(SB), X0
|
||||||
|
VMOVDQA X0, 0(R10)
|
||||||
|
XORQ CX, 0(R10) // 0(R10) = ·AVX_iv3 ^ (CX || 0)
|
||||||
|
|
||||||
|
VMOVDQU 0(AX), X10
|
||||||
|
VMOVDQU 16(AX), X11
|
||||||
|
VMOVDQU 32(AX), X2
|
||||||
|
VMOVDQU 48(AX), X3
|
||||||
|
|
||||||
|
MOVQ 0(BX), R8
|
||||||
|
MOVQ 8(BX), R9
|
||||||
|
|
||||||
|
loop:
|
||||||
|
ADDQ $128, R8
|
||||||
|
CMPQ R8, $128
|
||||||
|
JGE noinc
|
||||||
|
INCQ R9
|
||||||
|
|
||||||
|
noinc:
|
||||||
|
VMOVQ_R8_X15
|
||||||
|
VPINSRQ_1_R9_X15
|
||||||
|
|
||||||
|
VMOVDQA X10, X0
|
||||||
|
VMOVDQA X11, X1
|
||||||
|
VMOVDQU ·AVX_iv0<>(SB), X4
|
||||||
|
VMOVDQU ·AVX_iv1<>(SB), X5
|
||||||
|
VMOVDQU ·AVX_iv2<>(SB), X6
|
||||||
|
|
||||||
|
VPXOR X15, X6, X6
|
||||||
|
VMOVDQA 0(R10), X7
|
||||||
|
|
||||||
|
LOAD_MSG_AVX_0_2_4_6_1_3_5_7()
|
||||||
|
VMOVDQA X12, 16(R10)
|
||||||
|
VMOVDQA X13, 32(R10)
|
||||||
|
VMOVDQA X14, 48(R10)
|
||||||
|
VMOVDQA X15, 64(R10)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX(8, 10, 12, 14, 9, 11, 13, 15)
|
||||||
|
VMOVDQA X12, 80(R10)
|
||||||
|
VMOVDQA X13, 96(R10)
|
||||||
|
VMOVDQA X14, 112(R10)
|
||||||
|
VMOVDQA X15, 128(R10)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX(14, 4, 9, 13, 10, 8, 15, 6)
|
||||||
|
VMOVDQA X12, 144(R10)
|
||||||
|
VMOVDQA X13, 160(R10)
|
||||||
|
VMOVDQA X14, 176(R10)
|
||||||
|
VMOVDQA X15, 192(R10)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX_1_0_11_5_12_2_7_3()
|
||||||
|
VMOVDQA X12, 208(R10)
|
||||||
|
VMOVDQA X13, 224(R10)
|
||||||
|
VMOVDQA X14, 240(R10)
|
||||||
|
VMOVDQA X15, 256(R10)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX_11_12_5_15_8_0_2_13()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX(10, 3, 7, 9, 14, 6, 1, 4)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX(7, 3, 13, 11, 9, 1, 12, 14)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX_2_5_4_15_6_10_0_8()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX_9_5_2_10_0_7_4_15()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX(14, 11, 6, 3, 1, 12, 8, 13)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX_2_6_0_8_12_10_11_3()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX(4, 7, 15, 1, 13, 5, 14, 9)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX(12, 1, 14, 4, 5, 15, 13, 10)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX_0_6_9_8_7_3_2_11()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX(13, 7, 12, 3, 11, 14, 1, 9)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX_5_15_8_2_0_4_6_10()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX_6_14_11_0_15_9_3_8()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX_12_13_1_10_2_7_4_5()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
LOAD_MSG_AVX(10, 8, 7, 1, 2, 4, 6, 5)
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
LOAD_MSG_AVX_15_9_3_13_11_14_12_0()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, X12, X13, X14, X15, X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, 16(R10), 32(R10), 48(R10), 64(R10), X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, 80(R10), 96(R10), 112(R10), 128(R10), X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, 144(R10), 160(R10), 176(R10), 192(R10), X15, X8, X9)
|
||||||
|
SHUFFLE_AVX()
|
||||||
|
HALF_ROUND_AVX(X0, X1, X2, X3, X4, X5, X6, X7, 208(R10), 224(R10), 240(R10), 256(R10), X15, X8, X9)
|
||||||
|
SHUFFLE_AVX_INV()
|
||||||
|
|
||||||
|
VMOVDQU 32(AX), X14
|
||||||
|
VMOVDQU 48(AX), X15
|
||||||
|
VPXOR X0, X10, X10
|
||||||
|
VPXOR X1, X11, X11
|
||||||
|
VPXOR X2, X14, X14
|
||||||
|
VPXOR X3, X15, X15
|
||||||
|
VPXOR X4, X10, X10
|
||||||
|
VPXOR X5, X11, X11
|
||||||
|
VPXOR X6, X14, X2
|
||||||
|
VPXOR X7, X15, X3
|
||||||
|
VMOVDQU X2, 32(AX)
|
||||||
|
VMOVDQU X3, 48(AX)
|
||||||
|
|
||||||
|
LEAQ 128(SI), SI
|
||||||
|
SUBQ $128, DI
|
||||||
|
JNE loop
|
||||||
|
|
||||||
|
VMOVDQU X10, 0(AX)
|
||||||
|
VMOVDQU X11, 16(AX)
|
||||||
|
|
||||||
|
MOVQ R8, 0(BX)
|
||||||
|
MOVQ R9, 8(BX)
|
||||||
|
VZEROUPPER
|
||||||
|
|
||||||
|
RET
|
25
vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go
generated
vendored
Normal file
25
vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
//go:build !go1.7 && amd64 && gc && !purego
|
||||||
|
// +build !go1.7,amd64,gc,!purego
|
||||||
|
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
import "golang.org/x/sys/cpu"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
useSSE4 = cpu.X86.HasSSE41
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
|
||||||
|
func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
|
||||||
|
if useSSE4 {
|
||||||
|
hashBlocksSSE4(h, c, flag, blocks)
|
||||||
|
} else {
|
||||||
|
hashBlocksGeneric(h, c, flag, blocks)
|
||||||
|
}
|
||||||
|
}
|
279
vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s
generated
vendored
Normal file
279
vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
//go:build amd64 && gc && !purego
|
||||||
|
// +build amd64,gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
DATA ·iv0<>+0x00(SB)/8, $0x6a09e667f3bcc908
|
||||||
|
DATA ·iv0<>+0x08(SB)/8, $0xbb67ae8584caa73b
|
||||||
|
GLOBL ·iv0<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·iv1<>+0x00(SB)/8, $0x3c6ef372fe94f82b
|
||||||
|
DATA ·iv1<>+0x08(SB)/8, $0xa54ff53a5f1d36f1
|
||||||
|
GLOBL ·iv1<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·iv2<>+0x00(SB)/8, $0x510e527fade682d1
|
||||||
|
DATA ·iv2<>+0x08(SB)/8, $0x9b05688c2b3e6c1f
|
||||||
|
GLOBL ·iv2<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·iv3<>+0x00(SB)/8, $0x1f83d9abfb41bd6b
|
||||||
|
DATA ·iv3<>+0x08(SB)/8, $0x5be0cd19137e2179
|
||||||
|
GLOBL ·iv3<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·c40<>+0x00(SB)/8, $0x0201000706050403
|
||||||
|
DATA ·c40<>+0x08(SB)/8, $0x0a09080f0e0d0c0b
|
||||||
|
GLOBL ·c40<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
DATA ·c48<>+0x00(SB)/8, $0x0100070605040302
|
||||||
|
DATA ·c48<>+0x08(SB)/8, $0x09080f0e0d0c0b0a
|
||||||
|
GLOBL ·c48<>(SB), (NOPTR+RODATA), $16
|
||||||
|
|
||||||
|
#define SHUFFLE(v2, v3, v4, v5, v6, v7, t1, t2) \
|
||||||
|
MOVO v4, t1; \
|
||||||
|
MOVO v5, v4; \
|
||||||
|
MOVO t1, v5; \
|
||||||
|
MOVO v6, t1; \
|
||||||
|
PUNPCKLQDQ v6, t2; \
|
||||||
|
PUNPCKHQDQ v7, v6; \
|
||||||
|
PUNPCKHQDQ t2, v6; \
|
||||||
|
PUNPCKLQDQ v7, t2; \
|
||||||
|
MOVO t1, v7; \
|
||||||
|
MOVO v2, t1; \
|
||||||
|
PUNPCKHQDQ t2, v7; \
|
||||||
|
PUNPCKLQDQ v3, t2; \
|
||||||
|
PUNPCKHQDQ t2, v2; \
|
||||||
|
PUNPCKLQDQ t1, t2; \
|
||||||
|
PUNPCKHQDQ t2, v3
|
||||||
|
|
||||||
|
#define SHUFFLE_INV(v2, v3, v4, v5, v6, v7, t1, t2) \
|
||||||
|
MOVO v4, t1; \
|
||||||
|
MOVO v5, v4; \
|
||||||
|
MOVO t1, v5; \
|
||||||
|
MOVO v2, t1; \
|
||||||
|
PUNPCKLQDQ v2, t2; \
|
||||||
|
PUNPCKHQDQ v3, v2; \
|
||||||
|
PUNPCKHQDQ t2, v2; \
|
||||||
|
PUNPCKLQDQ v3, t2; \
|
||||||
|
MOVO t1, v3; \
|
||||||
|
MOVO v6, t1; \
|
||||||
|
PUNPCKHQDQ t2, v3; \
|
||||||
|
PUNPCKLQDQ v7, t2; \
|
||||||
|
PUNPCKHQDQ t2, v6; \
|
||||||
|
PUNPCKLQDQ t1, t2; \
|
||||||
|
PUNPCKHQDQ t2, v7
|
||||||
|
|
||||||
|
#define HALF_ROUND(v0, v1, v2, v3, v4, v5, v6, v7, m0, m1, m2, m3, t0, c40, c48) \
|
||||||
|
PADDQ m0, v0; \
|
||||||
|
PADDQ m1, v1; \
|
||||||
|
PADDQ v2, v0; \
|
||||||
|
PADDQ v3, v1; \
|
||||||
|
PXOR v0, v6; \
|
||||||
|
PXOR v1, v7; \
|
||||||
|
PSHUFD $0xB1, v6, v6; \
|
||||||
|
PSHUFD $0xB1, v7, v7; \
|
||||||
|
PADDQ v6, v4; \
|
||||||
|
PADDQ v7, v5; \
|
||||||
|
PXOR v4, v2; \
|
||||||
|
PXOR v5, v3; \
|
||||||
|
PSHUFB c40, v2; \
|
||||||
|
PSHUFB c40, v3; \
|
||||||
|
PADDQ m2, v0; \
|
||||||
|
PADDQ m3, v1; \
|
||||||
|
PADDQ v2, v0; \
|
||||||
|
PADDQ v3, v1; \
|
||||||
|
PXOR v0, v6; \
|
||||||
|
PXOR v1, v7; \
|
||||||
|
PSHUFB c48, v6; \
|
||||||
|
PSHUFB c48, v7; \
|
||||||
|
PADDQ v6, v4; \
|
||||||
|
PADDQ v7, v5; \
|
||||||
|
PXOR v4, v2; \
|
||||||
|
PXOR v5, v3; \
|
||||||
|
MOVOU v2, t0; \
|
||||||
|
PADDQ v2, t0; \
|
||||||
|
PSRLQ $63, v2; \
|
||||||
|
PXOR t0, v2; \
|
||||||
|
MOVOU v3, t0; \
|
||||||
|
PADDQ v3, t0; \
|
||||||
|
PSRLQ $63, v3; \
|
||||||
|
PXOR t0, v3
|
||||||
|
|
||||||
|
#define LOAD_MSG(m0, m1, m2, m3, src, i0, i1, i2, i3, i4, i5, i6, i7) \
|
||||||
|
MOVQ i0*8(src), m0; \
|
||||||
|
PINSRQ $1, i1*8(src), m0; \
|
||||||
|
MOVQ i2*8(src), m1; \
|
||||||
|
PINSRQ $1, i3*8(src), m1; \
|
||||||
|
MOVQ i4*8(src), m2; \
|
||||||
|
PINSRQ $1, i5*8(src), m2; \
|
||||||
|
MOVQ i6*8(src), m3; \
|
||||||
|
PINSRQ $1, i7*8(src), m3
|
||||||
|
|
||||||
|
// func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
|
||||||
|
TEXT ·hashBlocksSSE4(SB), 4, $288-48 // frame size = 272 + 16 byte alignment
|
||||||
|
MOVQ h+0(FP), AX
|
||||||
|
MOVQ c+8(FP), BX
|
||||||
|
MOVQ flag+16(FP), CX
|
||||||
|
MOVQ blocks_base+24(FP), SI
|
||||||
|
MOVQ blocks_len+32(FP), DI
|
||||||
|
|
||||||
|
MOVQ SP, R10
|
||||||
|
ADDQ $15, R10
|
||||||
|
ANDQ $~15, R10
|
||||||
|
|
||||||
|
MOVOU ·iv3<>(SB), X0
|
||||||
|
MOVO X0, 0(R10)
|
||||||
|
XORQ CX, 0(R10) // 0(R10) = ·iv3 ^ (CX || 0)
|
||||||
|
|
||||||
|
MOVOU ·c40<>(SB), X13
|
||||||
|
MOVOU ·c48<>(SB), X14
|
||||||
|
|
||||||
|
MOVOU 0(AX), X12
|
||||||
|
MOVOU 16(AX), X15
|
||||||
|
|
||||||
|
MOVQ 0(BX), R8
|
||||||
|
MOVQ 8(BX), R9
|
||||||
|
|
||||||
|
loop:
|
||||||
|
ADDQ $128, R8
|
||||||
|
CMPQ R8, $128
|
||||||
|
JGE noinc
|
||||||
|
INCQ R9
|
||||||
|
|
||||||
|
noinc:
|
||||||
|
MOVQ R8, X8
|
||||||
|
PINSRQ $1, R9, X8
|
||||||
|
|
||||||
|
MOVO X12, X0
|
||||||
|
MOVO X15, X1
|
||||||
|
MOVOU 32(AX), X2
|
||||||
|
MOVOU 48(AX), X3
|
||||||
|
MOVOU ·iv0<>(SB), X4
|
||||||
|
MOVOU ·iv1<>(SB), X5
|
||||||
|
MOVOU ·iv2<>(SB), X6
|
||||||
|
|
||||||
|
PXOR X8, X6
|
||||||
|
MOVO 0(R10), X7
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 0, 2, 4, 6, 1, 3, 5, 7)
|
||||||
|
MOVO X8, 16(R10)
|
||||||
|
MOVO X9, 32(R10)
|
||||||
|
MOVO X10, 48(R10)
|
||||||
|
MOVO X11, 64(R10)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 8, 10, 12, 14, 9, 11, 13, 15)
|
||||||
|
MOVO X8, 80(R10)
|
||||||
|
MOVO X9, 96(R10)
|
||||||
|
MOVO X10, 112(R10)
|
||||||
|
MOVO X11, 128(R10)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 14, 4, 9, 13, 10, 8, 15, 6)
|
||||||
|
MOVO X8, 144(R10)
|
||||||
|
MOVO X9, 160(R10)
|
||||||
|
MOVO X10, 176(R10)
|
||||||
|
MOVO X11, 192(R10)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 1, 0, 11, 5, 12, 2, 7, 3)
|
||||||
|
MOVO X8, 208(R10)
|
||||||
|
MOVO X9, 224(R10)
|
||||||
|
MOVO X10, 240(R10)
|
||||||
|
MOVO X11, 256(R10)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 11, 12, 5, 15, 8, 0, 2, 13)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 10, 3, 7, 9, 14, 6, 1, 4)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 7, 3, 13, 11, 9, 1, 12, 14)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 2, 5, 4, 15, 6, 10, 0, 8)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 9, 5, 2, 10, 0, 7, 4, 15)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 14, 11, 6, 3, 1, 12, 8, 13)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 2, 6, 0, 8, 12, 10, 11, 3)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 4, 7, 15, 1, 13, 5, 14, 9)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 12, 1, 14, 4, 5, 15, 13, 10)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 0, 6, 9, 8, 7, 3, 2, 11)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 13, 7, 12, 3, 11, 14, 1, 9)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 5, 15, 8, 2, 0, 4, 6, 10)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 6, 14, 11, 0, 15, 9, 3, 8)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 12, 13, 1, 10, 2, 7, 4, 5)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 10, 8, 7, 1, 2, 4, 6, 5)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
LOAD_MSG(X8, X9, X10, X11, SI, 15, 9, 3, 13, 11, 14, 12, 0)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, 16(R10), 32(R10), 48(R10), 64(R10), X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, 80(R10), 96(R10), 112(R10), 128(R10), X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, 144(R10), 160(R10), 176(R10), 192(R10), X11, X13, X14)
|
||||||
|
SHUFFLE(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
HALF_ROUND(X0, X1, X2, X3, X4, X5, X6, X7, 208(R10), 224(R10), 240(R10), 256(R10), X11, X13, X14)
|
||||||
|
SHUFFLE_INV(X2, X3, X4, X5, X6, X7, X8, X9)
|
||||||
|
|
||||||
|
MOVOU 32(AX), X10
|
||||||
|
MOVOU 48(AX), X11
|
||||||
|
PXOR X0, X12
|
||||||
|
PXOR X1, X15
|
||||||
|
PXOR X2, X10
|
||||||
|
PXOR X3, X11
|
||||||
|
PXOR X4, X12
|
||||||
|
PXOR X5, X15
|
||||||
|
PXOR X6, X10
|
||||||
|
PXOR X7, X11
|
||||||
|
MOVOU X10, 32(AX)
|
||||||
|
MOVOU X11, 48(AX)
|
||||||
|
|
||||||
|
LEAQ 128(SI), SI
|
||||||
|
SUBQ $128, DI
|
||||||
|
JNE loop
|
||||||
|
|
||||||
|
MOVOU X12, 0(AX)
|
||||||
|
MOVOU X15, 16(AX)
|
||||||
|
|
||||||
|
MOVQ R8, 0(BX)
|
||||||
|
MOVQ R9, 8(BX)
|
||||||
|
|
||||||
|
RET
|
182
vendor/golang.org/x/crypto/blake2b/blake2b_generic.go
generated
vendored
Normal file
182
vendor/golang.org/x/crypto/blake2b/blake2b_generic.go
generated
vendored
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"math/bits"
|
||||||
|
)
|
||||||
|
|
||||||
|
// the precomputed values for BLAKE2b
|
||||||
|
// there are 12 16-byte arrays - one for each round
|
||||||
|
// the entries are calculated from the sigma constants.
|
||||||
|
var precomputed = [12][16]byte{
|
||||||
|
{0, 2, 4, 6, 1, 3, 5, 7, 8, 10, 12, 14, 9, 11, 13, 15},
|
||||||
|
{14, 4, 9, 13, 10, 8, 15, 6, 1, 0, 11, 5, 12, 2, 7, 3},
|
||||||
|
{11, 12, 5, 15, 8, 0, 2, 13, 10, 3, 7, 9, 14, 6, 1, 4},
|
||||||
|
{7, 3, 13, 11, 9, 1, 12, 14, 2, 5, 4, 15, 6, 10, 0, 8},
|
||||||
|
{9, 5, 2, 10, 0, 7, 4, 15, 14, 11, 6, 3, 1, 12, 8, 13},
|
||||||
|
{2, 6, 0, 8, 12, 10, 11, 3, 4, 7, 15, 1, 13, 5, 14, 9},
|
||||||
|
{12, 1, 14, 4, 5, 15, 13, 10, 0, 6, 9, 8, 7, 3, 2, 11},
|
||||||
|
{13, 7, 12, 3, 11, 14, 1, 9, 5, 15, 8, 2, 0, 4, 6, 10},
|
||||||
|
{6, 14, 11, 0, 15, 9, 3, 8, 12, 13, 1, 10, 2, 7, 4, 5},
|
||||||
|
{10, 8, 7, 1, 2, 4, 6, 5, 15, 9, 3, 13, 11, 14, 12, 0},
|
||||||
|
{0, 2, 4, 6, 1, 3, 5, 7, 8, 10, 12, 14, 9, 11, 13, 15}, // equal to the first
|
||||||
|
{14, 4, 9, 13, 10, 8, 15, 6, 1, 0, 11, 5, 12, 2, 7, 3}, // equal to the second
|
||||||
|
}
|
||||||
|
|
||||||
|
func hashBlocksGeneric(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
|
||||||
|
var m [16]uint64
|
||||||
|
c0, c1 := c[0], c[1]
|
||||||
|
|
||||||
|
for i := 0; i < len(blocks); {
|
||||||
|
c0 += BlockSize
|
||||||
|
if c0 < BlockSize {
|
||||||
|
c1++
|
||||||
|
}
|
||||||
|
|
||||||
|
v0, v1, v2, v3, v4, v5, v6, v7 := h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7]
|
||||||
|
v8, v9, v10, v11, v12, v13, v14, v15 := iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7]
|
||||||
|
v12 ^= c0
|
||||||
|
v13 ^= c1
|
||||||
|
v14 ^= flag
|
||||||
|
|
||||||
|
for j := range m {
|
||||||
|
m[j] = binary.LittleEndian.Uint64(blocks[i:])
|
||||||
|
i += 8
|
||||||
|
}
|
||||||
|
|
||||||
|
for j := range precomputed {
|
||||||
|
s := &(precomputed[j])
|
||||||
|
|
||||||
|
v0 += m[s[0]]
|
||||||
|
v0 += v4
|
||||||
|
v12 ^= v0
|
||||||
|
v12 = bits.RotateLeft64(v12, -32)
|
||||||
|
v8 += v12
|
||||||
|
v4 ^= v8
|
||||||
|
v4 = bits.RotateLeft64(v4, -24)
|
||||||
|
v1 += m[s[1]]
|
||||||
|
v1 += v5
|
||||||
|
v13 ^= v1
|
||||||
|
v13 = bits.RotateLeft64(v13, -32)
|
||||||
|
v9 += v13
|
||||||
|
v5 ^= v9
|
||||||
|
v5 = bits.RotateLeft64(v5, -24)
|
||||||
|
v2 += m[s[2]]
|
||||||
|
v2 += v6
|
||||||
|
v14 ^= v2
|
||||||
|
v14 = bits.RotateLeft64(v14, -32)
|
||||||
|
v10 += v14
|
||||||
|
v6 ^= v10
|
||||||
|
v6 = bits.RotateLeft64(v6, -24)
|
||||||
|
v3 += m[s[3]]
|
||||||
|
v3 += v7
|
||||||
|
v15 ^= v3
|
||||||
|
v15 = bits.RotateLeft64(v15, -32)
|
||||||
|
v11 += v15
|
||||||
|
v7 ^= v11
|
||||||
|
v7 = bits.RotateLeft64(v7, -24)
|
||||||
|
|
||||||
|
v0 += m[s[4]]
|
||||||
|
v0 += v4
|
||||||
|
v12 ^= v0
|
||||||
|
v12 = bits.RotateLeft64(v12, -16)
|
||||||
|
v8 += v12
|
||||||
|
v4 ^= v8
|
||||||
|
v4 = bits.RotateLeft64(v4, -63)
|
||||||
|
v1 += m[s[5]]
|
||||||
|
v1 += v5
|
||||||
|
v13 ^= v1
|
||||||
|
v13 = bits.RotateLeft64(v13, -16)
|
||||||
|
v9 += v13
|
||||||
|
v5 ^= v9
|
||||||
|
v5 = bits.RotateLeft64(v5, -63)
|
||||||
|
v2 += m[s[6]]
|
||||||
|
v2 += v6
|
||||||
|
v14 ^= v2
|
||||||
|
v14 = bits.RotateLeft64(v14, -16)
|
||||||
|
v10 += v14
|
||||||
|
v6 ^= v10
|
||||||
|
v6 = bits.RotateLeft64(v6, -63)
|
||||||
|
v3 += m[s[7]]
|
||||||
|
v3 += v7
|
||||||
|
v15 ^= v3
|
||||||
|
v15 = bits.RotateLeft64(v15, -16)
|
||||||
|
v11 += v15
|
||||||
|
v7 ^= v11
|
||||||
|
v7 = bits.RotateLeft64(v7, -63)
|
||||||
|
|
||||||
|
v0 += m[s[8]]
|
||||||
|
v0 += v5
|
||||||
|
v15 ^= v0
|
||||||
|
v15 = bits.RotateLeft64(v15, -32)
|
||||||
|
v10 += v15
|
||||||
|
v5 ^= v10
|
||||||
|
v5 = bits.RotateLeft64(v5, -24)
|
||||||
|
v1 += m[s[9]]
|
||||||
|
v1 += v6
|
||||||
|
v12 ^= v1
|
||||||
|
v12 = bits.RotateLeft64(v12, -32)
|
||||||
|
v11 += v12
|
||||||
|
v6 ^= v11
|
||||||
|
v6 = bits.RotateLeft64(v6, -24)
|
||||||
|
v2 += m[s[10]]
|
||||||
|
v2 += v7
|
||||||
|
v13 ^= v2
|
||||||
|
v13 = bits.RotateLeft64(v13, -32)
|
||||||
|
v8 += v13
|
||||||
|
v7 ^= v8
|
||||||
|
v7 = bits.RotateLeft64(v7, -24)
|
||||||
|
v3 += m[s[11]]
|
||||||
|
v3 += v4
|
||||||
|
v14 ^= v3
|
||||||
|
v14 = bits.RotateLeft64(v14, -32)
|
||||||
|
v9 += v14
|
||||||
|
v4 ^= v9
|
||||||
|
v4 = bits.RotateLeft64(v4, -24)
|
||||||
|
|
||||||
|
v0 += m[s[12]]
|
||||||
|
v0 += v5
|
||||||
|
v15 ^= v0
|
||||||
|
v15 = bits.RotateLeft64(v15, -16)
|
||||||
|
v10 += v15
|
||||||
|
v5 ^= v10
|
||||||
|
v5 = bits.RotateLeft64(v5, -63)
|
||||||
|
v1 += m[s[13]]
|
||||||
|
v1 += v6
|
||||||
|
v12 ^= v1
|
||||||
|
v12 = bits.RotateLeft64(v12, -16)
|
||||||
|
v11 += v12
|
||||||
|
v6 ^= v11
|
||||||
|
v6 = bits.RotateLeft64(v6, -63)
|
||||||
|
v2 += m[s[14]]
|
||||||
|
v2 += v7
|
||||||
|
v13 ^= v2
|
||||||
|
v13 = bits.RotateLeft64(v13, -16)
|
||||||
|
v8 += v13
|
||||||
|
v7 ^= v8
|
||||||
|
v7 = bits.RotateLeft64(v7, -63)
|
||||||
|
v3 += m[s[15]]
|
||||||
|
v3 += v4
|
||||||
|
v14 ^= v3
|
||||||
|
v14 = bits.RotateLeft64(v14, -16)
|
||||||
|
v9 += v14
|
||||||
|
v4 ^= v9
|
||||||
|
v4 = bits.RotateLeft64(v4, -63)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
h[0] ^= v0 ^ v8
|
||||||
|
h[1] ^= v1 ^ v9
|
||||||
|
h[2] ^= v2 ^ v10
|
||||||
|
h[3] ^= v3 ^ v11
|
||||||
|
h[4] ^= v4 ^ v12
|
||||||
|
h[5] ^= v5 ^ v13
|
||||||
|
h[6] ^= v6 ^ v14
|
||||||
|
h[7] ^= v7 ^ v15
|
||||||
|
}
|
||||||
|
c[0], c[1] = c0, c1
|
||||||
|
}
|
12
vendor/golang.org/x/crypto/blake2b/blake2b_ref.go
generated
vendored
Normal file
12
vendor/golang.org/x/crypto/blake2b/blake2b_ref.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
//go:build !amd64 || purego || !gc
|
||||||
|
// +build !amd64 purego !gc
|
||||||
|
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
|
||||||
|
hashBlocksGeneric(h, c, flag, blocks)
|
||||||
|
}
|
177
vendor/golang.org/x/crypto/blake2b/blake2x.go
generated
vendored
Normal file
177
vendor/golang.org/x/crypto/blake2b/blake2x.go
generated
vendored
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// XOF defines the interface to hash functions that
|
||||||
|
// support arbitrary-length output.
|
||||||
|
type XOF interface {
|
||||||
|
// Write absorbs more data into the hash's state. It panics if called
|
||||||
|
// after Read.
|
||||||
|
io.Writer
|
||||||
|
|
||||||
|
// Read reads more output from the hash. It returns io.EOF if the limit
|
||||||
|
// has been reached.
|
||||||
|
io.Reader
|
||||||
|
|
||||||
|
// Clone returns a copy of the XOF in its current state.
|
||||||
|
Clone() XOF
|
||||||
|
|
||||||
|
// Reset resets the XOF to its initial state.
|
||||||
|
Reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputLengthUnknown can be used as the size argument to NewXOF to indicate
|
||||||
|
// the length of the output is not known in advance.
|
||||||
|
const OutputLengthUnknown = 0
|
||||||
|
|
||||||
|
// magicUnknownOutputLength is a magic value for the output size that indicates
|
||||||
|
// an unknown number of output bytes.
|
||||||
|
const magicUnknownOutputLength = (1 << 32) - 1
|
||||||
|
|
||||||
|
// maxOutputLength is the absolute maximum number of bytes to produce when the
|
||||||
|
// number of output bytes is unknown.
|
||||||
|
const maxOutputLength = (1 << 32) * 64
|
||||||
|
|
||||||
|
// NewXOF creates a new variable-output-length hash. The hash either produce a
|
||||||
|
// known number of bytes (1 <= size < 2**32-1), or an unknown number of bytes
|
||||||
|
// (size == OutputLengthUnknown). In the latter case, an absolute limit of
|
||||||
|
// 256GiB applies.
|
||||||
|
//
|
||||||
|
// A non-nil key turns the hash into a MAC. The key must between
|
||||||
|
// zero and 32 bytes long.
|
||||||
|
func NewXOF(size uint32, key []byte) (XOF, error) {
|
||||||
|
if len(key) > Size {
|
||||||
|
return nil, errKeySize
|
||||||
|
}
|
||||||
|
if size == magicUnknownOutputLength {
|
||||||
|
// 2^32-1 indicates an unknown number of bytes and thus isn't a
|
||||||
|
// valid length.
|
||||||
|
return nil, errors.New("blake2b: XOF length too large")
|
||||||
|
}
|
||||||
|
if size == OutputLengthUnknown {
|
||||||
|
size = magicUnknownOutputLength
|
||||||
|
}
|
||||||
|
x := &xof{
|
||||||
|
d: digest{
|
||||||
|
size: Size,
|
||||||
|
keyLen: len(key),
|
||||||
|
},
|
||||||
|
length: size,
|
||||||
|
}
|
||||||
|
copy(x.d.key[:], key)
|
||||||
|
x.Reset()
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type xof struct {
|
||||||
|
d digest
|
||||||
|
length uint32
|
||||||
|
remaining uint64
|
||||||
|
cfg, root, block [Size]byte
|
||||||
|
offset int
|
||||||
|
nodeOffset uint32
|
||||||
|
readMode bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *xof) Write(p []byte) (n int, err error) {
|
||||||
|
if x.readMode {
|
||||||
|
panic("blake2b: write to XOF after read")
|
||||||
|
}
|
||||||
|
return x.d.Write(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *xof) Clone() XOF {
|
||||||
|
clone := *x
|
||||||
|
return &clone
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *xof) Reset() {
|
||||||
|
x.cfg[0] = byte(Size)
|
||||||
|
binary.LittleEndian.PutUint32(x.cfg[4:], uint32(Size)) // leaf length
|
||||||
|
binary.LittleEndian.PutUint32(x.cfg[12:], x.length) // XOF length
|
||||||
|
x.cfg[17] = byte(Size) // inner hash size
|
||||||
|
|
||||||
|
x.d.Reset()
|
||||||
|
x.d.h[1] ^= uint64(x.length) << 32
|
||||||
|
|
||||||
|
x.remaining = uint64(x.length)
|
||||||
|
if x.remaining == magicUnknownOutputLength {
|
||||||
|
x.remaining = maxOutputLength
|
||||||
|
}
|
||||||
|
x.offset, x.nodeOffset = 0, 0
|
||||||
|
x.readMode = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *xof) Read(p []byte) (n int, err error) {
|
||||||
|
if !x.readMode {
|
||||||
|
x.d.finalize(&x.root)
|
||||||
|
x.readMode = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if x.remaining == 0 {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
n = len(p)
|
||||||
|
if uint64(n) > x.remaining {
|
||||||
|
n = int(x.remaining)
|
||||||
|
p = p[:n]
|
||||||
|
}
|
||||||
|
|
||||||
|
if x.offset > 0 {
|
||||||
|
blockRemaining := Size - x.offset
|
||||||
|
if n < blockRemaining {
|
||||||
|
x.offset += copy(p, x.block[x.offset:])
|
||||||
|
x.remaining -= uint64(n)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
copy(p, x.block[x.offset:])
|
||||||
|
p = p[blockRemaining:]
|
||||||
|
x.offset = 0
|
||||||
|
x.remaining -= uint64(blockRemaining)
|
||||||
|
}
|
||||||
|
|
||||||
|
for len(p) >= Size {
|
||||||
|
binary.LittleEndian.PutUint32(x.cfg[8:], x.nodeOffset)
|
||||||
|
x.nodeOffset++
|
||||||
|
|
||||||
|
x.d.initConfig(&x.cfg)
|
||||||
|
x.d.Write(x.root[:])
|
||||||
|
x.d.finalize(&x.block)
|
||||||
|
|
||||||
|
copy(p, x.block[:])
|
||||||
|
p = p[Size:]
|
||||||
|
x.remaining -= uint64(Size)
|
||||||
|
}
|
||||||
|
|
||||||
|
if todo := len(p); todo > 0 {
|
||||||
|
if x.remaining < uint64(Size) {
|
||||||
|
x.cfg[0] = byte(x.remaining)
|
||||||
|
}
|
||||||
|
binary.LittleEndian.PutUint32(x.cfg[8:], x.nodeOffset)
|
||||||
|
x.nodeOffset++
|
||||||
|
|
||||||
|
x.d.initConfig(&x.cfg)
|
||||||
|
x.d.Write(x.root[:])
|
||||||
|
x.d.finalize(&x.block)
|
||||||
|
|
||||||
|
x.offset = copy(p, x.block[:todo])
|
||||||
|
x.remaining -= uint64(todo)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *digest) initConfig(cfg *[Size]byte) {
|
||||||
|
d.offset, d.c[0], d.c[1] = 0, 0, 0
|
||||||
|
for i := range d.h {
|
||||||
|
d.h[i] = iv[i] ^ binary.LittleEndian.Uint64(cfg[i*8:])
|
||||||
|
}
|
||||||
|
}
|
33
vendor/golang.org/x/crypto/blake2b/register.go
generated
vendored
Normal file
33
vendor/golang.org/x/crypto/blake2b/register.go
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
//go:build go1.9
|
||||||
|
// +build go1.9
|
||||||
|
|
||||||
|
package blake2b
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"hash"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
newHash256 := func() hash.Hash {
|
||||||
|
h, _ := New256(nil)
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
newHash384 := func() hash.Hash {
|
||||||
|
h, _ := New384(nil)
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
|
newHash512 := func() hash.Hash {
|
||||||
|
h, _ := New512(nil)
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
|
crypto.RegisterHash(crypto.BLAKE2b_256, newHash256)
|
||||||
|
crypto.RegisterHash(crypto.BLAKE2b_384, newHash384)
|
||||||
|
crypto.RegisterHash(crypto.BLAKE2b_512, newHash512)
|
||||||
|
}
|
145
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
Normal file
145
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
// Package curve25519 provides an implementation of the X25519 function, which
|
||||||
|
// performs scalar multiplication on the elliptic curve known as Curve25519.
|
||||||
|
// See RFC 7748.
|
||||||
|
package curve25519 // import "golang.org/x/crypto/curve25519"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/subtle"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/curve25519/internal/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ScalarMult sets dst to the product scalar * point.
|
||||||
|
//
|
||||||
|
// Deprecated: when provided a low-order point, ScalarMult will set dst to all
|
||||||
|
// zeroes, irrespective of the scalar. Instead, use the X25519 function, which
|
||||||
|
// will return an error.
|
||||||
|
func ScalarMult(dst, scalar, point *[32]byte) {
|
||||||
|
var e [32]byte
|
||||||
|
|
||||||
|
copy(e[:], scalar[:])
|
||||||
|
e[0] &= 248
|
||||||
|
e[31] &= 127
|
||||||
|
e[31] |= 64
|
||||||
|
|
||||||
|
var x1, x2, z2, x3, z3, tmp0, tmp1 field.Element
|
||||||
|
x1.SetBytes(point[:])
|
||||||
|
x2.One()
|
||||||
|
x3.Set(&x1)
|
||||||
|
z3.One()
|
||||||
|
|
||||||
|
swap := 0
|
||||||
|
for pos := 254; pos >= 0; pos-- {
|
||||||
|
b := e[pos/8] >> uint(pos&7)
|
||||||
|
b &= 1
|
||||||
|
swap ^= int(b)
|
||||||
|
x2.Swap(&x3, swap)
|
||||||
|
z2.Swap(&z3, swap)
|
||||||
|
swap = int(b)
|
||||||
|
|
||||||
|
tmp0.Subtract(&x3, &z3)
|
||||||
|
tmp1.Subtract(&x2, &z2)
|
||||||
|
x2.Add(&x2, &z2)
|
||||||
|
z2.Add(&x3, &z3)
|
||||||
|
z3.Multiply(&tmp0, &x2)
|
||||||
|
z2.Multiply(&z2, &tmp1)
|
||||||
|
tmp0.Square(&tmp1)
|
||||||
|
tmp1.Square(&x2)
|
||||||
|
x3.Add(&z3, &z2)
|
||||||
|
z2.Subtract(&z3, &z2)
|
||||||
|
x2.Multiply(&tmp1, &tmp0)
|
||||||
|
tmp1.Subtract(&tmp1, &tmp0)
|
||||||
|
z2.Square(&z2)
|
||||||
|
|
||||||
|
z3.Mult32(&tmp1, 121666)
|
||||||
|
x3.Square(&x3)
|
||||||
|
tmp0.Add(&tmp0, &z3)
|
||||||
|
z3.Multiply(&x1, &z2)
|
||||||
|
z2.Multiply(&tmp1, &tmp0)
|
||||||
|
}
|
||||||
|
|
||||||
|
x2.Swap(&x3, swap)
|
||||||
|
z2.Swap(&z3, swap)
|
||||||
|
|
||||||
|
z2.Invert(&z2)
|
||||||
|
x2.Multiply(&x2, &z2)
|
||||||
|
copy(dst[:], x2.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScalarBaseMult sets dst to the product scalar * base where base is the
|
||||||
|
// standard generator.
|
||||||
|
//
|
||||||
|
// It is recommended to use the X25519 function with Basepoint instead, as
|
||||||
|
// copying into fixed size arrays can lead to unexpected bugs.
|
||||||
|
func ScalarBaseMult(dst, scalar *[32]byte) {
|
||||||
|
ScalarMult(dst, scalar, &basePoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ScalarSize is the size of the scalar input to X25519.
|
||||||
|
ScalarSize = 32
|
||||||
|
// PointSize is the size of the point input to X25519.
|
||||||
|
PointSize = 32
|
||||||
|
)
|
||||||
|
|
||||||
|
// Basepoint is the canonical Curve25519 generator.
|
||||||
|
var Basepoint []byte
|
||||||
|
|
||||||
|
var basePoint = [32]byte{9, 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}
|
||||||
|
|
||||||
|
func init() { Basepoint = basePoint[:] }
|
||||||
|
|
||||||
|
func checkBasepoint() {
|
||||||
|
if subtle.ConstantTimeCompare(Basepoint, []byte{
|
||||||
|
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
}) != 1 {
|
||||||
|
panic("curve25519: global Basepoint value was modified")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// X25519 returns the result of the scalar multiplication (scalar * point),
|
||||||
|
// according to RFC 7748, Section 5. scalar, point and the return value are
|
||||||
|
// slices of 32 bytes.
|
||||||
|
//
|
||||||
|
// scalar can be generated at random, for example with crypto/rand. point should
|
||||||
|
// be either Basepoint or the output of another X25519 call.
|
||||||
|
//
|
||||||
|
// If point is Basepoint (but not if it's a different slice with the same
|
||||||
|
// contents) a precomputed implementation might be used for performance.
|
||||||
|
func X25519(scalar, point []byte) ([]byte, error) {
|
||||||
|
// Outline the body of function, to let the allocation be inlined in the
|
||||||
|
// caller, and possibly avoid escaping to the heap.
|
||||||
|
var dst [32]byte
|
||||||
|
return x25519(&dst, scalar, point)
|
||||||
|
}
|
||||||
|
|
||||||
|
func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) {
|
||||||
|
var in [32]byte
|
||||||
|
if l := len(scalar); l != 32 {
|
||||||
|
return nil, fmt.Errorf("bad scalar length: %d, expected %d", l, 32)
|
||||||
|
}
|
||||||
|
if l := len(point); l != 32 {
|
||||||
|
return nil, fmt.Errorf("bad point length: %d, expected %d", l, 32)
|
||||||
|
}
|
||||||
|
copy(in[:], scalar)
|
||||||
|
if &point[0] == &Basepoint[0] {
|
||||||
|
checkBasepoint()
|
||||||
|
ScalarBaseMult(dst, &in)
|
||||||
|
} else {
|
||||||
|
var base, zero [32]byte
|
||||||
|
copy(base[:], point)
|
||||||
|
ScalarMult(dst, &in, &base)
|
||||||
|
if subtle.ConstantTimeCompare(dst[:], zero[:]) == 1 {
|
||||||
|
return nil, fmt.Errorf("bad input point: low order point")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dst[:], nil
|
||||||
|
}
|
7
vendor/golang.org/x/crypto/curve25519/internal/field/README
generated
vendored
Normal file
7
vendor/golang.org/x/crypto/curve25519/internal/field/README
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
This package is kept in sync with crypto/ed25519/internal/edwards25519/field in
|
||||||
|
the standard library.
|
||||||
|
|
||||||
|
If there are any changes in the standard library that need to be synced to this
|
||||||
|
package, run sync.sh. It will not overwrite any local changes made since the
|
||||||
|
previous sync, so it's ok to land changes in this package first, and then sync
|
||||||
|
to the standard library later.
|
416
vendor/golang.org/x/crypto/curve25519/internal/field/fe.go
generated
vendored
Normal file
416
vendor/golang.org/x/crypto/curve25519/internal/field/fe.go
generated
vendored
Normal file
|
@ -0,0 +1,416 @@
|
||||||
|
// Copyright (c) 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.
|
||||||
|
|
||||||
|
// Package field implements fast arithmetic modulo 2^255-19.
|
||||||
|
package field
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/subtle"
|
||||||
|
"encoding/binary"
|
||||||
|
"math/bits"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Element represents an element of the field GF(2^255-19). Note that this
|
||||||
|
// is not a cryptographically secure group, and should only be used to interact
|
||||||
|
// with edwards25519.Point coordinates.
|
||||||
|
//
|
||||||
|
// This type works similarly to math/big.Int, and all arguments and receivers
|
||||||
|
// are allowed to alias.
|
||||||
|
//
|
||||||
|
// The zero value is a valid zero element.
|
||||||
|
type Element struct {
|
||||||
|
// An element t represents the integer
|
||||||
|
// t.l0 + t.l1*2^51 + t.l2*2^102 + t.l3*2^153 + t.l4*2^204
|
||||||
|
//
|
||||||
|
// Between operations, all limbs are expected to be lower than 2^52.
|
||||||
|
l0 uint64
|
||||||
|
l1 uint64
|
||||||
|
l2 uint64
|
||||||
|
l3 uint64
|
||||||
|
l4 uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
const maskLow51Bits uint64 = (1 << 51) - 1
|
||||||
|
|
||||||
|
var feZero = &Element{0, 0, 0, 0, 0}
|
||||||
|
|
||||||
|
// Zero sets v = 0, and returns v.
|
||||||
|
func (v *Element) Zero() *Element {
|
||||||
|
*v = *feZero
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
var feOne = &Element{1, 0, 0, 0, 0}
|
||||||
|
|
||||||
|
// One sets v = 1, and returns v.
|
||||||
|
func (v *Element) One() *Element {
|
||||||
|
*v = *feOne
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// reduce reduces v modulo 2^255 - 19 and returns it.
|
||||||
|
func (v *Element) reduce() *Element {
|
||||||
|
v.carryPropagate()
|
||||||
|
|
||||||
|
// After the light reduction we now have a field element representation
|
||||||
|
// v < 2^255 + 2^13 * 19, but need v < 2^255 - 19.
|
||||||
|
|
||||||
|
// If v >= 2^255 - 19, then v + 19 >= 2^255, which would overflow 2^255 - 1,
|
||||||
|
// generating a carry. That is, c will be 0 if v < 2^255 - 19, and 1 otherwise.
|
||||||
|
c := (v.l0 + 19) >> 51
|
||||||
|
c = (v.l1 + c) >> 51
|
||||||
|
c = (v.l2 + c) >> 51
|
||||||
|
c = (v.l3 + c) >> 51
|
||||||
|
c = (v.l4 + c) >> 51
|
||||||
|
|
||||||
|
// If v < 2^255 - 19 and c = 0, this will be a no-op. Otherwise, it's
|
||||||
|
// effectively applying the reduction identity to the carry.
|
||||||
|
v.l0 += 19 * c
|
||||||
|
|
||||||
|
v.l1 += v.l0 >> 51
|
||||||
|
v.l0 = v.l0 & maskLow51Bits
|
||||||
|
v.l2 += v.l1 >> 51
|
||||||
|
v.l1 = v.l1 & maskLow51Bits
|
||||||
|
v.l3 += v.l2 >> 51
|
||||||
|
v.l2 = v.l2 & maskLow51Bits
|
||||||
|
v.l4 += v.l3 >> 51
|
||||||
|
v.l3 = v.l3 & maskLow51Bits
|
||||||
|
// no additional carry
|
||||||
|
v.l4 = v.l4 & maskLow51Bits
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add sets v = a + b, and returns v.
|
||||||
|
func (v *Element) Add(a, b *Element) *Element {
|
||||||
|
v.l0 = a.l0 + b.l0
|
||||||
|
v.l1 = a.l1 + b.l1
|
||||||
|
v.l2 = a.l2 + b.l2
|
||||||
|
v.l3 = a.l3 + b.l3
|
||||||
|
v.l4 = a.l4 + b.l4
|
||||||
|
// Using the generic implementation here is actually faster than the
|
||||||
|
// assembly. Probably because the body of this function is so simple that
|
||||||
|
// the compiler can figure out better optimizations by inlining the carry
|
||||||
|
// propagation. TODO
|
||||||
|
return v.carryPropagateGeneric()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtract sets v = a - b, and returns v.
|
||||||
|
func (v *Element) Subtract(a, b *Element) *Element {
|
||||||
|
// We first add 2 * p, to guarantee the subtraction won't underflow, and
|
||||||
|
// then subtract b (which can be up to 2^255 + 2^13 * 19).
|
||||||
|
v.l0 = (a.l0 + 0xFFFFFFFFFFFDA) - b.l0
|
||||||
|
v.l1 = (a.l1 + 0xFFFFFFFFFFFFE) - b.l1
|
||||||
|
v.l2 = (a.l2 + 0xFFFFFFFFFFFFE) - b.l2
|
||||||
|
v.l3 = (a.l3 + 0xFFFFFFFFFFFFE) - b.l3
|
||||||
|
v.l4 = (a.l4 + 0xFFFFFFFFFFFFE) - b.l4
|
||||||
|
return v.carryPropagate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Negate sets v = -a, and returns v.
|
||||||
|
func (v *Element) Negate(a *Element) *Element {
|
||||||
|
return v.Subtract(feZero, a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invert sets v = 1/z mod p, and returns v.
|
||||||
|
//
|
||||||
|
// If z == 0, Invert returns v = 0.
|
||||||
|
func (v *Element) Invert(z *Element) *Element {
|
||||||
|
// Inversion is implemented as exponentiation with exponent p − 2. It uses the
|
||||||
|
// same sequence of 255 squarings and 11 multiplications as [Curve25519].
|
||||||
|
var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t Element
|
||||||
|
|
||||||
|
z2.Square(z) // 2
|
||||||
|
t.Square(&z2) // 4
|
||||||
|
t.Square(&t) // 8
|
||||||
|
z9.Multiply(&t, z) // 9
|
||||||
|
z11.Multiply(&z9, &z2) // 11
|
||||||
|
t.Square(&z11) // 22
|
||||||
|
z2_5_0.Multiply(&t, &z9) // 31 = 2^5 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_5_0) // 2^6 - 2^1
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
t.Square(&t) // 2^10 - 2^5
|
||||||
|
}
|
||||||
|
z2_10_0.Multiply(&t, &z2_5_0) // 2^10 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_10_0) // 2^11 - 2^1
|
||||||
|
for i := 0; i < 9; i++ {
|
||||||
|
t.Square(&t) // 2^20 - 2^10
|
||||||
|
}
|
||||||
|
z2_20_0.Multiply(&t, &z2_10_0) // 2^20 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_20_0) // 2^21 - 2^1
|
||||||
|
for i := 0; i < 19; i++ {
|
||||||
|
t.Square(&t) // 2^40 - 2^20
|
||||||
|
}
|
||||||
|
t.Multiply(&t, &z2_20_0) // 2^40 - 2^0
|
||||||
|
|
||||||
|
t.Square(&t) // 2^41 - 2^1
|
||||||
|
for i := 0; i < 9; i++ {
|
||||||
|
t.Square(&t) // 2^50 - 2^10
|
||||||
|
}
|
||||||
|
z2_50_0.Multiply(&t, &z2_10_0) // 2^50 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_50_0) // 2^51 - 2^1
|
||||||
|
for i := 0; i < 49; i++ {
|
||||||
|
t.Square(&t) // 2^100 - 2^50
|
||||||
|
}
|
||||||
|
z2_100_0.Multiply(&t, &z2_50_0) // 2^100 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_100_0) // 2^101 - 2^1
|
||||||
|
for i := 0; i < 99; i++ {
|
||||||
|
t.Square(&t) // 2^200 - 2^100
|
||||||
|
}
|
||||||
|
t.Multiply(&t, &z2_100_0) // 2^200 - 2^0
|
||||||
|
|
||||||
|
t.Square(&t) // 2^201 - 2^1
|
||||||
|
for i := 0; i < 49; i++ {
|
||||||
|
t.Square(&t) // 2^250 - 2^50
|
||||||
|
}
|
||||||
|
t.Multiply(&t, &z2_50_0) // 2^250 - 2^0
|
||||||
|
|
||||||
|
t.Square(&t) // 2^251 - 2^1
|
||||||
|
t.Square(&t) // 2^252 - 2^2
|
||||||
|
t.Square(&t) // 2^253 - 2^3
|
||||||
|
t.Square(&t) // 2^254 - 2^4
|
||||||
|
t.Square(&t) // 2^255 - 2^5
|
||||||
|
|
||||||
|
return v.Multiply(&t, &z11) // 2^255 - 21
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set sets v = a, and returns v.
|
||||||
|
func (v *Element) Set(a *Element) *Element {
|
||||||
|
*v = *a
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBytes sets v to x, which must be a 32-byte little-endian encoding.
|
||||||
|
//
|
||||||
|
// Consistent with RFC 7748, the most significant bit (the high bit of the
|
||||||
|
// last byte) is ignored, and non-canonical values (2^255-19 through 2^255-1)
|
||||||
|
// are accepted. Note that this is laxer than specified by RFC 8032.
|
||||||
|
func (v *Element) SetBytes(x []byte) *Element {
|
||||||
|
if len(x) != 32 {
|
||||||
|
panic("edwards25519: invalid field element input size")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bits 0:51 (bytes 0:8, bits 0:64, shift 0, mask 51).
|
||||||
|
v.l0 = binary.LittleEndian.Uint64(x[0:8])
|
||||||
|
v.l0 &= maskLow51Bits
|
||||||
|
// Bits 51:102 (bytes 6:14, bits 48:112, shift 3, mask 51).
|
||||||
|
v.l1 = binary.LittleEndian.Uint64(x[6:14]) >> 3
|
||||||
|
v.l1 &= maskLow51Bits
|
||||||
|
// Bits 102:153 (bytes 12:20, bits 96:160, shift 6, mask 51).
|
||||||
|
v.l2 = binary.LittleEndian.Uint64(x[12:20]) >> 6
|
||||||
|
v.l2 &= maskLow51Bits
|
||||||
|
// Bits 153:204 (bytes 19:27, bits 152:216, shift 1, mask 51).
|
||||||
|
v.l3 = binary.LittleEndian.Uint64(x[19:27]) >> 1
|
||||||
|
v.l3 &= maskLow51Bits
|
||||||
|
// Bits 204:251 (bytes 24:32, bits 192:256, shift 12, mask 51).
|
||||||
|
// Note: not bytes 25:33, shift 4, to avoid overread.
|
||||||
|
v.l4 = binary.LittleEndian.Uint64(x[24:32]) >> 12
|
||||||
|
v.l4 &= maskLow51Bits
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bytes returns the canonical 32-byte little-endian encoding of v.
|
||||||
|
func (v *Element) Bytes() []byte {
|
||||||
|
// This function is outlined to make the allocations inline in the caller
|
||||||
|
// rather than happen on the heap.
|
||||||
|
var out [32]byte
|
||||||
|
return v.bytes(&out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Element) bytes(out *[32]byte) []byte {
|
||||||
|
t := *v
|
||||||
|
t.reduce()
|
||||||
|
|
||||||
|
var buf [8]byte
|
||||||
|
for i, l := range [5]uint64{t.l0, t.l1, t.l2, t.l3, t.l4} {
|
||||||
|
bitsOffset := i * 51
|
||||||
|
binary.LittleEndian.PutUint64(buf[:], l<<uint(bitsOffset%8))
|
||||||
|
for i, bb := range buf {
|
||||||
|
off := bitsOffset/8 + i
|
||||||
|
if off >= len(out) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
out[off] |= bb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out[:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal returns 1 if v and u are equal, and 0 otherwise.
|
||||||
|
func (v *Element) Equal(u *Element) int {
|
||||||
|
sa, sv := u.Bytes(), v.Bytes()
|
||||||
|
return subtle.ConstantTimeCompare(sa, sv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// mask64Bits returns 0xffffffff if cond is 1, and 0 otherwise.
|
||||||
|
func mask64Bits(cond int) uint64 { return ^(uint64(cond) - 1) }
|
||||||
|
|
||||||
|
// Select sets v to a if cond == 1, and to b if cond == 0.
|
||||||
|
func (v *Element) Select(a, b *Element, cond int) *Element {
|
||||||
|
m := mask64Bits(cond)
|
||||||
|
v.l0 = (m & a.l0) | (^m & b.l0)
|
||||||
|
v.l1 = (m & a.l1) | (^m & b.l1)
|
||||||
|
v.l2 = (m & a.l2) | (^m & b.l2)
|
||||||
|
v.l3 = (m & a.l3) | (^m & b.l3)
|
||||||
|
v.l4 = (m & a.l4) | (^m & b.l4)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap swaps v and u if cond == 1 or leaves them unchanged if cond == 0, and returns v.
|
||||||
|
func (v *Element) Swap(u *Element, cond int) {
|
||||||
|
m := mask64Bits(cond)
|
||||||
|
t := m & (v.l0 ^ u.l0)
|
||||||
|
v.l0 ^= t
|
||||||
|
u.l0 ^= t
|
||||||
|
t = m & (v.l1 ^ u.l1)
|
||||||
|
v.l1 ^= t
|
||||||
|
u.l1 ^= t
|
||||||
|
t = m & (v.l2 ^ u.l2)
|
||||||
|
v.l2 ^= t
|
||||||
|
u.l2 ^= t
|
||||||
|
t = m & (v.l3 ^ u.l3)
|
||||||
|
v.l3 ^= t
|
||||||
|
u.l3 ^= t
|
||||||
|
t = m & (v.l4 ^ u.l4)
|
||||||
|
v.l4 ^= t
|
||||||
|
u.l4 ^= t
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNegative returns 1 if v is negative, and 0 otherwise.
|
||||||
|
func (v *Element) IsNegative() int {
|
||||||
|
return int(v.Bytes()[0] & 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Absolute sets v to |u|, and returns v.
|
||||||
|
func (v *Element) Absolute(u *Element) *Element {
|
||||||
|
return v.Select(new(Element).Negate(u), u, u.IsNegative())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply sets v = x * y, and returns v.
|
||||||
|
func (v *Element) Multiply(x, y *Element) *Element {
|
||||||
|
feMul(v, x, y)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Square sets v = x * x, and returns v.
|
||||||
|
func (v *Element) Square(x *Element) *Element {
|
||||||
|
feSquare(v, x)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mult32 sets v = x * y, and returns v.
|
||||||
|
func (v *Element) Mult32(x *Element, y uint32) *Element {
|
||||||
|
x0lo, x0hi := mul51(x.l0, y)
|
||||||
|
x1lo, x1hi := mul51(x.l1, y)
|
||||||
|
x2lo, x2hi := mul51(x.l2, y)
|
||||||
|
x3lo, x3hi := mul51(x.l3, y)
|
||||||
|
x4lo, x4hi := mul51(x.l4, y)
|
||||||
|
v.l0 = x0lo + 19*x4hi // carried over per the reduction identity
|
||||||
|
v.l1 = x1lo + x0hi
|
||||||
|
v.l2 = x2lo + x1hi
|
||||||
|
v.l3 = x3lo + x2hi
|
||||||
|
v.l4 = x4lo + x3hi
|
||||||
|
// The hi portions are going to be only 32 bits, plus any previous excess,
|
||||||
|
// so we can skip the carry propagation.
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// mul51 returns lo + hi * 2⁵¹ = a * b.
|
||||||
|
func mul51(a uint64, b uint32) (lo uint64, hi uint64) {
|
||||||
|
mh, ml := bits.Mul64(a, uint64(b))
|
||||||
|
lo = ml & maskLow51Bits
|
||||||
|
hi = (mh << 13) | (ml >> 51)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pow22523 set v = x^((p-5)/8), and returns v. (p-5)/8 is 2^252-3.
|
||||||
|
func (v *Element) Pow22523(x *Element) *Element {
|
||||||
|
var t0, t1, t2 Element
|
||||||
|
|
||||||
|
t0.Square(x) // x^2
|
||||||
|
t1.Square(&t0) // x^4
|
||||||
|
t1.Square(&t1) // x^8
|
||||||
|
t1.Multiply(x, &t1) // x^9
|
||||||
|
t0.Multiply(&t0, &t1) // x^11
|
||||||
|
t0.Square(&t0) // x^22
|
||||||
|
t0.Multiply(&t1, &t0) // x^31
|
||||||
|
t1.Square(&t0) // x^62
|
||||||
|
for i := 1; i < 5; i++ { // x^992
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t0.Multiply(&t1, &t0) // x^1023 -> 1023 = 2^10 - 1
|
||||||
|
t1.Square(&t0) // 2^11 - 2
|
||||||
|
for i := 1; i < 10; i++ { // 2^20 - 2^10
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t1, &t0) // 2^20 - 1
|
||||||
|
t2.Square(&t1) // 2^21 - 2
|
||||||
|
for i := 1; i < 20; i++ { // 2^40 - 2^20
|
||||||
|
t2.Square(&t2)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t2, &t1) // 2^40 - 1
|
||||||
|
t1.Square(&t1) // 2^41 - 2
|
||||||
|
for i := 1; i < 10; i++ { // 2^50 - 2^10
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t0.Multiply(&t1, &t0) // 2^50 - 1
|
||||||
|
t1.Square(&t0) // 2^51 - 2
|
||||||
|
for i := 1; i < 50; i++ { // 2^100 - 2^50
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t1, &t0) // 2^100 - 1
|
||||||
|
t2.Square(&t1) // 2^101 - 2
|
||||||
|
for i := 1; i < 100; i++ { // 2^200 - 2^100
|
||||||
|
t2.Square(&t2)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t2, &t1) // 2^200 - 1
|
||||||
|
t1.Square(&t1) // 2^201 - 2
|
||||||
|
for i := 1; i < 50; i++ { // 2^250 - 2^50
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t0.Multiply(&t1, &t0) // 2^250 - 1
|
||||||
|
t0.Square(&t0) // 2^251 - 2
|
||||||
|
t0.Square(&t0) // 2^252 - 4
|
||||||
|
return v.Multiply(&t0, x) // 2^252 - 3 -> x^(2^252-3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sqrtM1 is 2^((p-1)/4), which squared is equal to -1 by Euler's Criterion.
|
||||||
|
var sqrtM1 = &Element{1718705420411056, 234908883556509,
|
||||||
|
2233514472574048, 2117202627021982, 765476049583133}
|
||||||
|
|
||||||
|
// SqrtRatio sets r to the non-negative square root of the ratio of u and v.
|
||||||
|
//
|
||||||
|
// If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatio
|
||||||
|
// sets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00,
|
||||||
|
// and returns r and 0.
|
||||||
|
func (r *Element) SqrtRatio(u, v *Element) (rr *Element, wasSquare int) {
|
||||||
|
var a, b Element
|
||||||
|
|
||||||
|
// r = (u * v3) * (u * v7)^((p-5)/8)
|
||||||
|
v2 := a.Square(v)
|
||||||
|
uv3 := b.Multiply(u, b.Multiply(v2, v))
|
||||||
|
uv7 := a.Multiply(uv3, a.Square(v2))
|
||||||
|
r.Multiply(uv3, r.Pow22523(uv7))
|
||||||
|
|
||||||
|
check := a.Multiply(v, a.Square(r)) // check = v * r^2
|
||||||
|
|
||||||
|
uNeg := b.Negate(u)
|
||||||
|
correctSignSqrt := check.Equal(u)
|
||||||
|
flippedSignSqrt := check.Equal(uNeg)
|
||||||
|
flippedSignSqrtI := check.Equal(uNeg.Multiply(uNeg, sqrtM1))
|
||||||
|
|
||||||
|
rPrime := b.Multiply(r, sqrtM1) // r_prime = SQRT_M1 * r
|
||||||
|
// r = CT_SELECT(r_prime IF flipped_sign_sqrt | flipped_sign_sqrt_i ELSE r)
|
||||||
|
r.Select(rPrime, r, flippedSignSqrt|flippedSignSqrtI)
|
||||||
|
|
||||||
|
r.Absolute(r) // Choose the nonnegative square root.
|
||||||
|
return r, correctSignSqrt | flippedSignSqrt
|
||||||
|
}
|
13
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go
generated
vendored
Normal file
13
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build amd64,gc,!purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
// feMul sets out = a * b. It works like feMulGeneric.
|
||||||
|
//go:noescape
|
||||||
|
func feMul(out *Element, a *Element, b *Element)
|
||||||
|
|
||||||
|
// feSquare sets out = a * a. It works like feSquareGeneric.
|
||||||
|
//go:noescape
|
||||||
|
func feSquare(out *Element, a *Element)
|
379
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s
generated
vendored
Normal file
379
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,379 @@
|
||||||
|
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build amd64 && gc && !purego
|
||||||
|
// +build amd64,gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func feMul(out *Element, a *Element, b *Element)
|
||||||
|
TEXT ·feMul(SB), NOSPLIT, $0-24
|
||||||
|
MOVQ a+8(FP), CX
|
||||||
|
MOVQ b+16(FP), BX
|
||||||
|
|
||||||
|
// r0 = a0×b0
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
MOVQ AX, DI
|
||||||
|
MOVQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a1×b4
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a2×b3
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a3×b2
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a4×b1
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r1 = a0×b1
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
MOVQ AX, R9
|
||||||
|
MOVQ DX, R8
|
||||||
|
|
||||||
|
// r1 += a1×b0
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r1 += 19×a2×b4
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r1 += 19×a3×b3
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r1 += 19×a4×b2
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r2 = a0×b2
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
MOVQ AX, R11
|
||||||
|
MOVQ DX, R10
|
||||||
|
|
||||||
|
// r2 += a1×b1
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r2 += a2×b0
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r2 += 19×a3×b4
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r2 += 19×a4×b3
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r3 = a0×b3
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
MOVQ AX, R13
|
||||||
|
MOVQ DX, R12
|
||||||
|
|
||||||
|
// r3 += a1×b2
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r3 += a2×b1
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r3 += a3×b0
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r3 += 19×a4×b4
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r4 = a0×b4
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
MOVQ AX, R15
|
||||||
|
MOVQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a1×b3
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a2×b2
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a3×b1
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a4×b0
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// First reduction chain
|
||||||
|
MOVQ $0x0007ffffffffffff, AX
|
||||||
|
SHLQ $0x0d, DI, SI
|
||||||
|
SHLQ $0x0d, R9, R8
|
||||||
|
SHLQ $0x0d, R11, R10
|
||||||
|
SHLQ $0x0d, R13, R12
|
||||||
|
SHLQ $0x0d, R15, R14
|
||||||
|
ANDQ AX, DI
|
||||||
|
IMUL3Q $0x13, R14, R14
|
||||||
|
ADDQ R14, DI
|
||||||
|
ANDQ AX, R9
|
||||||
|
ADDQ SI, R9
|
||||||
|
ANDQ AX, R11
|
||||||
|
ADDQ R8, R11
|
||||||
|
ANDQ AX, R13
|
||||||
|
ADDQ R10, R13
|
||||||
|
ANDQ AX, R15
|
||||||
|
ADDQ R12, R15
|
||||||
|
|
||||||
|
// Second reduction chain (carryPropagate)
|
||||||
|
MOVQ DI, SI
|
||||||
|
SHRQ $0x33, SI
|
||||||
|
MOVQ R9, R8
|
||||||
|
SHRQ $0x33, R8
|
||||||
|
MOVQ R11, R10
|
||||||
|
SHRQ $0x33, R10
|
||||||
|
MOVQ R13, R12
|
||||||
|
SHRQ $0x33, R12
|
||||||
|
MOVQ R15, R14
|
||||||
|
SHRQ $0x33, R14
|
||||||
|
ANDQ AX, DI
|
||||||
|
IMUL3Q $0x13, R14, R14
|
||||||
|
ADDQ R14, DI
|
||||||
|
ANDQ AX, R9
|
||||||
|
ADDQ SI, R9
|
||||||
|
ANDQ AX, R11
|
||||||
|
ADDQ R8, R11
|
||||||
|
ANDQ AX, R13
|
||||||
|
ADDQ R10, R13
|
||||||
|
ANDQ AX, R15
|
||||||
|
ADDQ R12, R15
|
||||||
|
|
||||||
|
// Store output
|
||||||
|
MOVQ out+0(FP), AX
|
||||||
|
MOVQ DI, (AX)
|
||||||
|
MOVQ R9, 8(AX)
|
||||||
|
MOVQ R11, 16(AX)
|
||||||
|
MOVQ R13, 24(AX)
|
||||||
|
MOVQ R15, 32(AX)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func feSquare(out *Element, a *Element)
|
||||||
|
TEXT ·feSquare(SB), NOSPLIT, $0-16
|
||||||
|
MOVQ a+8(FP), CX
|
||||||
|
|
||||||
|
// r0 = l0×l0
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ (CX)
|
||||||
|
MOVQ AX, SI
|
||||||
|
MOVQ DX, BX
|
||||||
|
|
||||||
|
// r0 += 38×l1×l4
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, SI
|
||||||
|
ADCQ DX, BX
|
||||||
|
|
||||||
|
// r0 += 38×l2×l3
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
ADDQ AX, SI
|
||||||
|
ADCQ DX, BX
|
||||||
|
|
||||||
|
// r1 = 2×l0×l1
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 8(CX)
|
||||||
|
MOVQ AX, R8
|
||||||
|
MOVQ DX, DI
|
||||||
|
|
||||||
|
// r1 += 38×l2×l4
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, R8
|
||||||
|
ADCQ DX, DI
|
||||||
|
|
||||||
|
// r1 += 19×l3×l3
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
ADDQ AX, R8
|
||||||
|
ADCQ DX, DI
|
||||||
|
|
||||||
|
// r2 = 2×l0×l2
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 16(CX)
|
||||||
|
MOVQ AX, R10
|
||||||
|
MOVQ DX, R9
|
||||||
|
|
||||||
|
// r2 += l1×l1
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 8(CX)
|
||||||
|
ADDQ AX, R10
|
||||||
|
ADCQ DX, R9
|
||||||
|
|
||||||
|
// r2 += 38×l3×l4
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, R10
|
||||||
|
ADCQ DX, R9
|
||||||
|
|
||||||
|
// r3 = 2×l0×l3
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
MOVQ AX, R12
|
||||||
|
MOVQ DX, R11
|
||||||
|
|
||||||
|
// r3 += 2×l1×l2
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x02, AX, AX
|
||||||
|
MULQ 16(CX)
|
||||||
|
ADDQ AX, R12
|
||||||
|
ADCQ DX, R11
|
||||||
|
|
||||||
|
// r3 += 19×l4×l4
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, R12
|
||||||
|
ADCQ DX, R11
|
||||||
|
|
||||||
|
// r4 = 2×l0×l4
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
MOVQ AX, R14
|
||||||
|
MOVQ DX, R13
|
||||||
|
|
||||||
|
// r4 += 2×l1×l3
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x02, AX, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
ADDQ AX, R14
|
||||||
|
ADCQ DX, R13
|
||||||
|
|
||||||
|
// r4 += l2×l2
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ 16(CX)
|
||||||
|
ADDQ AX, R14
|
||||||
|
ADCQ DX, R13
|
||||||
|
|
||||||
|
// First reduction chain
|
||||||
|
MOVQ $0x0007ffffffffffff, AX
|
||||||
|
SHLQ $0x0d, SI, BX
|
||||||
|
SHLQ $0x0d, R8, DI
|
||||||
|
SHLQ $0x0d, R10, R9
|
||||||
|
SHLQ $0x0d, R12, R11
|
||||||
|
SHLQ $0x0d, R14, R13
|
||||||
|
ANDQ AX, SI
|
||||||
|
IMUL3Q $0x13, R13, R13
|
||||||
|
ADDQ R13, SI
|
||||||
|
ANDQ AX, R8
|
||||||
|
ADDQ BX, R8
|
||||||
|
ANDQ AX, R10
|
||||||
|
ADDQ DI, R10
|
||||||
|
ANDQ AX, R12
|
||||||
|
ADDQ R9, R12
|
||||||
|
ANDQ AX, R14
|
||||||
|
ADDQ R11, R14
|
||||||
|
|
||||||
|
// Second reduction chain (carryPropagate)
|
||||||
|
MOVQ SI, BX
|
||||||
|
SHRQ $0x33, BX
|
||||||
|
MOVQ R8, DI
|
||||||
|
SHRQ $0x33, DI
|
||||||
|
MOVQ R10, R9
|
||||||
|
SHRQ $0x33, R9
|
||||||
|
MOVQ R12, R11
|
||||||
|
SHRQ $0x33, R11
|
||||||
|
MOVQ R14, R13
|
||||||
|
SHRQ $0x33, R13
|
||||||
|
ANDQ AX, SI
|
||||||
|
IMUL3Q $0x13, R13, R13
|
||||||
|
ADDQ R13, SI
|
||||||
|
ANDQ AX, R8
|
||||||
|
ADDQ BX, R8
|
||||||
|
ANDQ AX, R10
|
||||||
|
ADDQ DI, R10
|
||||||
|
ANDQ AX, R12
|
||||||
|
ADDQ R9, R12
|
||||||
|
ANDQ AX, R14
|
||||||
|
ADDQ R11, R14
|
||||||
|
|
||||||
|
// Store output
|
||||||
|
MOVQ out+0(FP), AX
|
||||||
|
MOVQ SI, (AX)
|
||||||
|
MOVQ R8, 8(AX)
|
||||||
|
MOVQ R10, 16(AX)
|
||||||
|
MOVQ R12, 24(AX)
|
||||||
|
MOVQ R14, 32(AX)
|
||||||
|
RET
|
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go
generated
vendored
Normal file
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright (c) 2019 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.
|
||||||
|
|
||||||
|
//go:build !amd64 || !gc || purego
|
||||||
|
// +build !amd64 !gc purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
func feMul(v, x, y *Element) { feMulGeneric(v, x, y) }
|
||||||
|
|
||||||
|
func feSquare(v, x *Element) { feSquareGeneric(v, x) }
|
16
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go
generated
vendored
Normal file
16
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright (c) 2020 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.
|
||||||
|
|
||||||
|
//go:build arm64 && gc && !purego
|
||||||
|
// +build arm64,gc,!purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func carryPropagate(v *Element)
|
||||||
|
|
||||||
|
func (v *Element) carryPropagate() *Element {
|
||||||
|
carryPropagate(v)
|
||||||
|
return v
|
||||||
|
}
|
43
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s
generated
vendored
Normal file
43
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright (c) 2020 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.
|
||||||
|
|
||||||
|
//go:build arm64 && gc && !purego
|
||||||
|
// +build arm64,gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// carryPropagate works exactly like carryPropagateGeneric and uses the
|
||||||
|
// same AND, ADD, and LSR+MADD instructions emitted by the compiler, but
|
||||||
|
// avoids loading R0-R4 twice and uses LDP and STP.
|
||||||
|
//
|
||||||
|
// See https://golang.org/issues/43145 for the main compiler issue.
|
||||||
|
//
|
||||||
|
// func carryPropagate(v *Element)
|
||||||
|
TEXT ·carryPropagate(SB),NOFRAME|NOSPLIT,$0-8
|
||||||
|
MOVD v+0(FP), R20
|
||||||
|
|
||||||
|
LDP 0(R20), (R0, R1)
|
||||||
|
LDP 16(R20), (R2, R3)
|
||||||
|
MOVD 32(R20), R4
|
||||||
|
|
||||||
|
AND $0x7ffffffffffff, R0, R10
|
||||||
|
AND $0x7ffffffffffff, R1, R11
|
||||||
|
AND $0x7ffffffffffff, R2, R12
|
||||||
|
AND $0x7ffffffffffff, R3, R13
|
||||||
|
AND $0x7ffffffffffff, R4, R14
|
||||||
|
|
||||||
|
ADD R0>>51, R11, R11
|
||||||
|
ADD R1>>51, R12, R12
|
||||||
|
ADD R2>>51, R13, R13
|
||||||
|
ADD R3>>51, R14, R14
|
||||||
|
// R4>>51 * 19 + R10 -> R10
|
||||||
|
LSR $51, R4, R21
|
||||||
|
MOVD $19, R22
|
||||||
|
MADD R22, R10, R21, R10
|
||||||
|
|
||||||
|
STP (R10, R11), 0(R20)
|
||||||
|
STP (R12, R13), 16(R20)
|
||||||
|
MOVD R14, 32(R20)
|
||||||
|
|
||||||
|
RET
|
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go
generated
vendored
Normal file
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright (c) 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.
|
||||||
|
|
||||||
|
//go:build !arm64 || !gc || purego
|
||||||
|
// +build !arm64 !gc purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
func (v *Element) carryPropagate() *Element {
|
||||||
|
return v.carryPropagateGeneric()
|
||||||
|
}
|
264
vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go
generated
vendored
Normal file
264
vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go
generated
vendored
Normal file
|
@ -0,0 +1,264 @@
|
||||||
|
// Copyright (c) 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.
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
import "math/bits"
|
||||||
|
|
||||||
|
// uint128 holds a 128-bit number as two 64-bit limbs, for use with the
|
||||||
|
// bits.Mul64 and bits.Add64 intrinsics.
|
||||||
|
type uint128 struct {
|
||||||
|
lo, hi uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// mul64 returns a * b.
|
||||||
|
func mul64(a, b uint64) uint128 {
|
||||||
|
hi, lo := bits.Mul64(a, b)
|
||||||
|
return uint128{lo, hi}
|
||||||
|
}
|
||||||
|
|
||||||
|
// addMul64 returns v + a * b.
|
||||||
|
func addMul64(v uint128, a, b uint64) uint128 {
|
||||||
|
hi, lo := bits.Mul64(a, b)
|
||||||
|
lo, c := bits.Add64(lo, v.lo, 0)
|
||||||
|
hi, _ = bits.Add64(hi, v.hi, c)
|
||||||
|
return uint128{lo, hi}
|
||||||
|
}
|
||||||
|
|
||||||
|
// shiftRightBy51 returns a >> 51. a is assumed to be at most 115 bits.
|
||||||
|
func shiftRightBy51(a uint128) uint64 {
|
||||||
|
return (a.hi << (64 - 51)) | (a.lo >> 51)
|
||||||
|
}
|
||||||
|
|
||||||
|
func feMulGeneric(v, a, b *Element) {
|
||||||
|
a0 := a.l0
|
||||||
|
a1 := a.l1
|
||||||
|
a2 := a.l2
|
||||||
|
a3 := a.l3
|
||||||
|
a4 := a.l4
|
||||||
|
|
||||||
|
b0 := b.l0
|
||||||
|
b1 := b.l1
|
||||||
|
b2 := b.l2
|
||||||
|
b3 := b.l3
|
||||||
|
b4 := b.l4
|
||||||
|
|
||||||
|
// Limb multiplication works like pen-and-paper columnar multiplication, but
|
||||||
|
// with 51-bit limbs instead of digits.
|
||||||
|
//
|
||||||
|
// a4 a3 a2 a1 a0 x
|
||||||
|
// b4 b3 b2 b1 b0 =
|
||||||
|
// ------------------------
|
||||||
|
// a4b0 a3b0 a2b0 a1b0 a0b0 +
|
||||||
|
// a4b1 a3b1 a2b1 a1b1 a0b1 +
|
||||||
|
// a4b2 a3b2 a2b2 a1b2 a0b2 +
|
||||||
|
// a4b3 a3b3 a2b3 a1b3 a0b3 +
|
||||||
|
// a4b4 a3b4 a2b4 a1b4 a0b4 =
|
||||||
|
// ----------------------------------------------
|
||||||
|
// r8 r7 r6 r5 r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// We can then use the reduction identity (a * 2²⁵⁵ + b = a * 19 + b) to
|
||||||
|
// reduce the limbs that would overflow 255 bits. r5 * 2²⁵⁵ becomes 19 * r5,
|
||||||
|
// r6 * 2³⁰⁶ becomes 19 * r6 * 2⁵¹, etc.
|
||||||
|
//
|
||||||
|
// Reduction can be carried out simultaneously to multiplication. For
|
||||||
|
// example, we do not compute r5: whenever the result of a multiplication
|
||||||
|
// belongs to r5, like a1b4, we multiply it by 19 and add the result to r0.
|
||||||
|
//
|
||||||
|
// a4b0 a3b0 a2b0 a1b0 a0b0 +
|
||||||
|
// a3b1 a2b1 a1b1 a0b1 19×a4b1 +
|
||||||
|
// a2b2 a1b2 a0b2 19×a4b2 19×a3b2 +
|
||||||
|
// a1b3 a0b3 19×a4b3 19×a3b3 19×a2b3 +
|
||||||
|
// a0b4 19×a4b4 19×a3b4 19×a2b4 19×a1b4 =
|
||||||
|
// --------------------------------------
|
||||||
|
// r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// Finally we add up the columns into wide, overlapping limbs.
|
||||||
|
|
||||||
|
a1_19 := a1 * 19
|
||||||
|
a2_19 := a2 * 19
|
||||||
|
a3_19 := a3 * 19
|
||||||
|
a4_19 := a4 * 19
|
||||||
|
|
||||||
|
// r0 = a0×b0 + 19×(a1×b4 + a2×b3 + a3×b2 + a4×b1)
|
||||||
|
r0 := mul64(a0, b0)
|
||||||
|
r0 = addMul64(r0, a1_19, b4)
|
||||||
|
r0 = addMul64(r0, a2_19, b3)
|
||||||
|
r0 = addMul64(r0, a3_19, b2)
|
||||||
|
r0 = addMul64(r0, a4_19, b1)
|
||||||
|
|
||||||
|
// r1 = a0×b1 + a1×b0 + 19×(a2×b4 + a3×b3 + a4×b2)
|
||||||
|
r1 := mul64(a0, b1)
|
||||||
|
r1 = addMul64(r1, a1, b0)
|
||||||
|
r1 = addMul64(r1, a2_19, b4)
|
||||||
|
r1 = addMul64(r1, a3_19, b3)
|
||||||
|
r1 = addMul64(r1, a4_19, b2)
|
||||||
|
|
||||||
|
// r2 = a0×b2 + a1×b1 + a2×b0 + 19×(a3×b4 + a4×b3)
|
||||||
|
r2 := mul64(a0, b2)
|
||||||
|
r2 = addMul64(r2, a1, b1)
|
||||||
|
r2 = addMul64(r2, a2, b0)
|
||||||
|
r2 = addMul64(r2, a3_19, b4)
|
||||||
|
r2 = addMul64(r2, a4_19, b3)
|
||||||
|
|
||||||
|
// r3 = a0×b3 + a1×b2 + a2×b1 + a3×b0 + 19×a4×b4
|
||||||
|
r3 := mul64(a0, b3)
|
||||||
|
r3 = addMul64(r3, a1, b2)
|
||||||
|
r3 = addMul64(r3, a2, b1)
|
||||||
|
r3 = addMul64(r3, a3, b0)
|
||||||
|
r3 = addMul64(r3, a4_19, b4)
|
||||||
|
|
||||||
|
// r4 = a0×b4 + a1×b3 + a2×b2 + a3×b1 + a4×b0
|
||||||
|
r4 := mul64(a0, b4)
|
||||||
|
r4 = addMul64(r4, a1, b3)
|
||||||
|
r4 = addMul64(r4, a2, b2)
|
||||||
|
r4 = addMul64(r4, a3, b1)
|
||||||
|
r4 = addMul64(r4, a4, b0)
|
||||||
|
|
||||||
|
// After the multiplication, we need to reduce (carry) the five coefficients
|
||||||
|
// to obtain a result with limbs that are at most slightly larger than 2⁵¹,
|
||||||
|
// to respect the Element invariant.
|
||||||
|
//
|
||||||
|
// Overall, the reduction works the same as carryPropagate, except with
|
||||||
|
// wider inputs: we take the carry for each coefficient by shifting it right
|
||||||
|
// by 51, and add it to the limb above it. The top carry is multiplied by 19
|
||||||
|
// according to the reduction identity and added to the lowest limb.
|
||||||
|
//
|
||||||
|
// The largest coefficient (r0) will be at most 111 bits, which guarantees
|
||||||
|
// that all carries are at most 111 - 51 = 60 bits, which fits in a uint64.
|
||||||
|
//
|
||||||
|
// r0 = a0×b0 + 19×(a1×b4 + a2×b3 + a3×b2 + a4×b1)
|
||||||
|
// r0 < 2⁵²×2⁵² + 19×(2⁵²×2⁵² + 2⁵²×2⁵² + 2⁵²×2⁵² + 2⁵²×2⁵²)
|
||||||
|
// r0 < (1 + 19 × 4) × 2⁵² × 2⁵²
|
||||||
|
// r0 < 2⁷ × 2⁵² × 2⁵²
|
||||||
|
// r0 < 2¹¹¹
|
||||||
|
//
|
||||||
|
// Moreover, the top coefficient (r4) is at most 107 bits, so c4 is at most
|
||||||
|
// 56 bits, and c4 * 19 is at most 61 bits, which again fits in a uint64 and
|
||||||
|
// allows us to easily apply the reduction identity.
|
||||||
|
//
|
||||||
|
// r4 = a0×b4 + a1×b3 + a2×b2 + a3×b1 + a4×b0
|
||||||
|
// r4 < 5 × 2⁵² × 2⁵²
|
||||||
|
// r4 < 2¹⁰⁷
|
||||||
|
//
|
||||||
|
|
||||||
|
c0 := shiftRightBy51(r0)
|
||||||
|
c1 := shiftRightBy51(r1)
|
||||||
|
c2 := shiftRightBy51(r2)
|
||||||
|
c3 := shiftRightBy51(r3)
|
||||||
|
c4 := shiftRightBy51(r4)
|
||||||
|
|
||||||
|
rr0 := r0.lo&maskLow51Bits + c4*19
|
||||||
|
rr1 := r1.lo&maskLow51Bits + c0
|
||||||
|
rr2 := r2.lo&maskLow51Bits + c1
|
||||||
|
rr3 := r3.lo&maskLow51Bits + c2
|
||||||
|
rr4 := r4.lo&maskLow51Bits + c3
|
||||||
|
|
||||||
|
// Now all coefficients fit into 64-bit registers but are still too large to
|
||||||
|
// be passed around as a Element. We therefore do one last carry chain,
|
||||||
|
// where the carries will be small enough to fit in the wiggle room above 2⁵¹.
|
||||||
|
*v = Element{rr0, rr1, rr2, rr3, rr4}
|
||||||
|
v.carryPropagate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func feSquareGeneric(v, a *Element) {
|
||||||
|
l0 := a.l0
|
||||||
|
l1 := a.l1
|
||||||
|
l2 := a.l2
|
||||||
|
l3 := a.l3
|
||||||
|
l4 := a.l4
|
||||||
|
|
||||||
|
// Squaring works precisely like multiplication above, but thanks to its
|
||||||
|
// symmetry we get to group a few terms together.
|
||||||
|
//
|
||||||
|
// l4 l3 l2 l1 l0 x
|
||||||
|
// l4 l3 l2 l1 l0 =
|
||||||
|
// ------------------------
|
||||||
|
// l4l0 l3l0 l2l0 l1l0 l0l0 +
|
||||||
|
// l4l1 l3l1 l2l1 l1l1 l0l1 +
|
||||||
|
// l4l2 l3l2 l2l2 l1l2 l0l2 +
|
||||||
|
// l4l3 l3l3 l2l3 l1l3 l0l3 +
|
||||||
|
// l4l4 l3l4 l2l4 l1l4 l0l4 =
|
||||||
|
// ----------------------------------------------
|
||||||
|
// r8 r7 r6 r5 r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// l4l0 l3l0 l2l0 l1l0 l0l0 +
|
||||||
|
// l3l1 l2l1 l1l1 l0l1 19×l4l1 +
|
||||||
|
// l2l2 l1l2 l0l2 19×l4l2 19×l3l2 +
|
||||||
|
// l1l3 l0l3 19×l4l3 19×l3l3 19×l2l3 +
|
||||||
|
// l0l4 19×l4l4 19×l3l4 19×l2l4 19×l1l4 =
|
||||||
|
// --------------------------------------
|
||||||
|
// r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// With precomputed 2×, 19×, and 2×19× terms, we can compute each limb with
|
||||||
|
// only three Mul64 and four Add64, instead of five and eight.
|
||||||
|
|
||||||
|
l0_2 := l0 * 2
|
||||||
|
l1_2 := l1 * 2
|
||||||
|
|
||||||
|
l1_38 := l1 * 38
|
||||||
|
l2_38 := l2 * 38
|
||||||
|
l3_38 := l3 * 38
|
||||||
|
|
||||||
|
l3_19 := l3 * 19
|
||||||
|
l4_19 := l4 * 19
|
||||||
|
|
||||||
|
// r0 = l0×l0 + 19×(l1×l4 + l2×l3 + l3×l2 + l4×l1) = l0×l0 + 19×2×(l1×l4 + l2×l3)
|
||||||
|
r0 := mul64(l0, l0)
|
||||||
|
r0 = addMul64(r0, l1_38, l4)
|
||||||
|
r0 = addMul64(r0, l2_38, l3)
|
||||||
|
|
||||||
|
// r1 = l0×l1 + l1×l0 + 19×(l2×l4 + l3×l3 + l4×l2) = 2×l0×l1 + 19×2×l2×l4 + 19×l3×l3
|
||||||
|
r1 := mul64(l0_2, l1)
|
||||||
|
r1 = addMul64(r1, l2_38, l4)
|
||||||
|
r1 = addMul64(r1, l3_19, l3)
|
||||||
|
|
||||||
|
// r2 = l0×l2 + l1×l1 + l2×l0 + 19×(l3×l4 + l4×l3) = 2×l0×l2 + l1×l1 + 19×2×l3×l4
|
||||||
|
r2 := mul64(l0_2, l2)
|
||||||
|
r2 = addMul64(r2, l1, l1)
|
||||||
|
r2 = addMul64(r2, l3_38, l4)
|
||||||
|
|
||||||
|
// r3 = l0×l3 + l1×l2 + l2×l1 + l3×l0 + 19×l4×l4 = 2×l0×l3 + 2×l1×l2 + 19×l4×l4
|
||||||
|
r3 := mul64(l0_2, l3)
|
||||||
|
r3 = addMul64(r3, l1_2, l2)
|
||||||
|
r3 = addMul64(r3, l4_19, l4)
|
||||||
|
|
||||||
|
// r4 = l0×l4 + l1×l3 + l2×l2 + l3×l1 + l4×l0 = 2×l0×l4 + 2×l1×l3 + l2×l2
|
||||||
|
r4 := mul64(l0_2, l4)
|
||||||
|
r4 = addMul64(r4, l1_2, l3)
|
||||||
|
r4 = addMul64(r4, l2, l2)
|
||||||
|
|
||||||
|
c0 := shiftRightBy51(r0)
|
||||||
|
c1 := shiftRightBy51(r1)
|
||||||
|
c2 := shiftRightBy51(r2)
|
||||||
|
c3 := shiftRightBy51(r3)
|
||||||
|
c4 := shiftRightBy51(r4)
|
||||||
|
|
||||||
|
rr0 := r0.lo&maskLow51Bits + c4*19
|
||||||
|
rr1 := r1.lo&maskLow51Bits + c0
|
||||||
|
rr2 := r2.lo&maskLow51Bits + c1
|
||||||
|
rr3 := r3.lo&maskLow51Bits + c2
|
||||||
|
rr4 := r4.lo&maskLow51Bits + c3
|
||||||
|
|
||||||
|
*v = Element{rr0, rr1, rr2, rr3, rr4}
|
||||||
|
v.carryPropagate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// carryPropagate brings the limbs below 52 bits by applying the reduction
|
||||||
|
// identity (a * 2²⁵⁵ + b = a * 19 + b) to the l4 carry. TODO inline
|
||||||
|
func (v *Element) carryPropagateGeneric() *Element {
|
||||||
|
c0 := v.l0 >> 51
|
||||||
|
c1 := v.l1 >> 51
|
||||||
|
c2 := v.l2 >> 51
|
||||||
|
c3 := v.l3 >> 51
|
||||||
|
c4 := v.l4 >> 51
|
||||||
|
|
||||||
|
v.l0 = v.l0&maskLow51Bits + c4*19
|
||||||
|
v.l1 = v.l1&maskLow51Bits + c0
|
||||||
|
v.l2 = v.l2&maskLow51Bits + c1
|
||||||
|
v.l3 = v.l3&maskLow51Bits + c2
|
||||||
|
v.l4 = v.l4&maskLow51Bits + c3
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
1
vendor/golang.org/x/crypto/curve25519/internal/field/sync.checkpoint
generated
vendored
Normal file
1
vendor/golang.org/x/crypto/curve25519/internal/field/sync.checkpoint
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
b0c49ae9f59d233526f8934262c5bbbe14d4358d
|
19
vendor/golang.org/x/crypto/curve25519/internal/field/sync.sh
generated
vendored
Normal file
19
vendor/golang.org/x/crypto/curve25519/internal/field/sync.sh
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#! /bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
STD_PATH=src/crypto/ed25519/internal/edwards25519/field
|
||||||
|
LOCAL_PATH=curve25519/internal/field
|
||||||
|
LAST_SYNC_REF=$(cat $LOCAL_PATH/sync.checkpoint)
|
||||||
|
|
||||||
|
git fetch https://go.googlesource.com/go master
|
||||||
|
|
||||||
|
if git diff --quiet $LAST_SYNC_REF:$STD_PATH FETCH_HEAD:$STD_PATH; then
|
||||||
|
echo "No changes."
|
||||||
|
else
|
||||||
|
NEW_REF=$(git rev-parse FETCH_HEAD | tee $LOCAL_PATH/sync.checkpoint)
|
||||||
|
echo "Applying changes from $LAST_SYNC_REF to $NEW_REF..."
|
||||||
|
git diff $LAST_SYNC_REF:$STD_PATH FETCH_HEAD:$STD_PATH | \
|
||||||
|
git apply -3 --directory=$LOCAL_PATH
|
||||||
|
fi
|
40
vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go
generated
vendored
Normal file
40
vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build !go1.13
|
||||||
|
// +build !go1.13
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
// Generic fallbacks for the math/bits intrinsics, copied from
|
||||||
|
// src/math/bits/bits.go. They were added in Go 1.12, but Add64 and Sum64 had
|
||||||
|
// variable time fallbacks until Go 1.13.
|
||||||
|
|
||||||
|
func bitsAdd64(x, y, carry uint64) (sum, carryOut uint64) {
|
||||||
|
sum = x + y + carry
|
||||||
|
carryOut = ((x & y) | ((x | y) &^ sum)) >> 63
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func bitsSub64(x, y, borrow uint64) (diff, borrowOut uint64) {
|
||||||
|
diff = x - y - borrow
|
||||||
|
borrowOut = ((^x & y) | (^(x ^ y) & diff)) >> 63
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func bitsMul64(x, y uint64) (hi, lo uint64) {
|
||||||
|
const mask32 = 1<<32 - 1
|
||||||
|
x0 := x & mask32
|
||||||
|
x1 := x >> 32
|
||||||
|
y0 := y & mask32
|
||||||
|
y1 := y >> 32
|
||||||
|
w0 := x0 * y0
|
||||||
|
t := x1*y0 + w0>>32
|
||||||
|
w1 := t & mask32
|
||||||
|
w2 := t >> 32
|
||||||
|
w1 += x0 * y1
|
||||||
|
hi = x1*y1 + w2 + w1>>32
|
||||||
|
lo = x * y
|
||||||
|
return
|
||||||
|
}
|
22
vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go
generated
vendored
Normal file
22
vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build go1.13
|
||||||
|
// +build go1.13
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
import "math/bits"
|
||||||
|
|
||||||
|
func bitsAdd64(x, y, carry uint64) (sum, carryOut uint64) {
|
||||||
|
return bits.Add64(x, y, carry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bitsSub64(x, y, borrow uint64) (diff, borrowOut uint64) {
|
||||||
|
return bits.Sub64(x, y, borrow)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bitsMul64(x, y uint64) (hi, lo uint64) {
|
||||||
|
return bits.Mul64(x, y)
|
||||||
|
}
|
10
vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go
generated
vendored
Normal file
10
vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build (!amd64 && !ppc64le && !s390x) || !gc || purego
|
||||||
|
// +build !amd64,!ppc64le,!s390x !gc purego
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
type mac struct{ macGeneric }
|
99
vendor/golang.org/x/crypto/internal/poly1305/poly1305.go
generated
vendored
Normal file
99
vendor/golang.org/x/crypto/internal/poly1305/poly1305.go
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// Package poly1305 implements Poly1305 one-time message authentication code as
|
||||||
|
// specified in https://cr.yp.to/mac/poly1305-20050329.pdf.
|
||||||
|
//
|
||||||
|
// Poly1305 is a fast, one-time authentication function. It is infeasible for an
|
||||||
|
// attacker to generate an authenticator for a message without the key. However, a
|
||||||
|
// key must only be used for a single message. Authenticating two different
|
||||||
|
// messages with the same key allows an attacker to forge authenticators for other
|
||||||
|
// messages with the same key.
|
||||||
|
//
|
||||||
|
// Poly1305 was originally coupled with AES in order to make Poly1305-AES. AES was
|
||||||
|
// used with a fixed key in order to generate one-time keys from an nonce.
|
||||||
|
// However, in this package AES isn't used and the one-time key is specified
|
||||||
|
// directly.
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
import "crypto/subtle"
|
||||||
|
|
||||||
|
// TagSize is the size, in bytes, of a poly1305 authenticator.
|
||||||
|
const TagSize = 16
|
||||||
|
|
||||||
|
// Sum generates an authenticator for msg using a one-time key and puts the
|
||||||
|
// 16-byte result into out. Authenticating two different messages with the same
|
||||||
|
// key allows an attacker to forge messages at will.
|
||||||
|
func Sum(out *[16]byte, m []byte, key *[32]byte) {
|
||||||
|
h := New(key)
|
||||||
|
h.Write(m)
|
||||||
|
h.Sum(out[:0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify returns true if mac is a valid authenticator for m with the given key.
|
||||||
|
func Verify(mac *[16]byte, m []byte, key *[32]byte) bool {
|
||||||
|
var tmp [16]byte
|
||||||
|
Sum(&tmp, m, key)
|
||||||
|
return subtle.ConstantTimeCompare(tmp[:], mac[:]) == 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// New returns a new MAC computing an authentication
|
||||||
|
// tag of all data written to it with the given key.
|
||||||
|
// This allows writing the message progressively instead
|
||||||
|
// of passing it as a single slice. Common users should use
|
||||||
|
// the Sum function instead.
|
||||||
|
//
|
||||||
|
// The key must be unique for each message, as authenticating
|
||||||
|
// two different messages with the same key allows an attacker
|
||||||
|
// to forge messages at will.
|
||||||
|
func New(key *[32]byte) *MAC {
|
||||||
|
m := &MAC{}
|
||||||
|
initialize(key, &m.macState)
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
// MAC is an io.Writer computing an authentication tag
|
||||||
|
// of the data written to it.
|
||||||
|
//
|
||||||
|
// MAC cannot be used like common hash.Hash implementations,
|
||||||
|
// because using a poly1305 key twice breaks its security.
|
||||||
|
// Therefore writing data to a running MAC after calling
|
||||||
|
// Sum or Verify causes it to panic.
|
||||||
|
type MAC struct {
|
||||||
|
mac // platform-dependent implementation
|
||||||
|
|
||||||
|
finalized bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size returns the number of bytes Sum will return.
|
||||||
|
func (h *MAC) Size() int { return TagSize }
|
||||||
|
|
||||||
|
// Write adds more data to the running message authentication code.
|
||||||
|
// It never returns an error.
|
||||||
|
//
|
||||||
|
// It must not be called after the first call of Sum or Verify.
|
||||||
|
func (h *MAC) Write(p []byte) (n int, err error) {
|
||||||
|
if h.finalized {
|
||||||
|
panic("poly1305: write to MAC after Sum or Verify")
|
||||||
|
}
|
||||||
|
return h.mac.Write(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum computes the authenticator of all data written to the
|
||||||
|
// message authentication code.
|
||||||
|
func (h *MAC) Sum(b []byte) []byte {
|
||||||
|
var mac [TagSize]byte
|
||||||
|
h.mac.Sum(&mac)
|
||||||
|
h.finalized = true
|
||||||
|
return append(b, mac[:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify returns whether the authenticator of all data written to
|
||||||
|
// the message authentication code matches the expected value.
|
||||||
|
func (h *MAC) Verify(expected []byte) bool {
|
||||||
|
var mac [TagSize]byte
|
||||||
|
h.mac.Sum(&mac)
|
||||||
|
h.finalized = true
|
||||||
|
return subtle.ConstantTimeCompare(expected, mac[:]) == 1
|
||||||
|
}
|
48
vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go
generated
vendored
Normal file
48
vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func update(state *macState, msg []byte)
|
||||||
|
|
||||||
|
// mac is a wrapper for macGeneric that redirects calls that would have gone to
|
||||||
|
// updateGeneric to update.
|
||||||
|
//
|
||||||
|
// Its Write and Sum methods are otherwise identical to the macGeneric ones, but
|
||||||
|
// using function pointers would carry a major performance cost.
|
||||||
|
type mac struct{ macGeneric }
|
||||||
|
|
||||||
|
func (h *mac) Write(p []byte) (int, error) {
|
||||||
|
nn := len(p)
|
||||||
|
if h.offset > 0 {
|
||||||
|
n := copy(h.buffer[h.offset:], p)
|
||||||
|
if h.offset+n < TagSize {
|
||||||
|
h.offset += n
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
p = p[n:]
|
||||||
|
h.offset = 0
|
||||||
|
update(&h.macState, h.buffer[:])
|
||||||
|
}
|
||||||
|
if n := len(p) - (len(p) % TagSize); n > 0 {
|
||||||
|
update(&h.macState, p[:n])
|
||||||
|
p = p[n:]
|
||||||
|
}
|
||||||
|
if len(p) > 0 {
|
||||||
|
h.offset += copy(h.buffer[h.offset:], p)
|
||||||
|
}
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *mac) Sum(out *[16]byte) {
|
||||||
|
state := h.macState
|
||||||
|
if h.offset > 0 {
|
||||||
|
update(&state, h.buffer[:h.offset])
|
||||||
|
}
|
||||||
|
finalize(out, &state.h, &state.s)
|
||||||
|
}
|
109
vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s
generated
vendored
Normal file
109
vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
#define POLY1305_ADD(msg, h0, h1, h2) \
|
||||||
|
ADDQ 0(msg), h0; \
|
||||||
|
ADCQ 8(msg), h1; \
|
||||||
|
ADCQ $1, h2; \
|
||||||
|
LEAQ 16(msg), msg
|
||||||
|
|
||||||
|
#define POLY1305_MUL(h0, h1, h2, r0, r1, t0, t1, t2, t3) \
|
||||||
|
MOVQ r0, AX; \
|
||||||
|
MULQ h0; \
|
||||||
|
MOVQ AX, t0; \
|
||||||
|
MOVQ DX, t1; \
|
||||||
|
MOVQ r0, AX; \
|
||||||
|
MULQ h1; \
|
||||||
|
ADDQ AX, t1; \
|
||||||
|
ADCQ $0, DX; \
|
||||||
|
MOVQ r0, t2; \
|
||||||
|
IMULQ h2, t2; \
|
||||||
|
ADDQ DX, t2; \
|
||||||
|
\
|
||||||
|
MOVQ r1, AX; \
|
||||||
|
MULQ h0; \
|
||||||
|
ADDQ AX, t1; \
|
||||||
|
ADCQ $0, DX; \
|
||||||
|
MOVQ DX, h0; \
|
||||||
|
MOVQ r1, t3; \
|
||||||
|
IMULQ h2, t3; \
|
||||||
|
MOVQ r1, AX; \
|
||||||
|
MULQ h1; \
|
||||||
|
ADDQ AX, t2; \
|
||||||
|
ADCQ DX, t3; \
|
||||||
|
ADDQ h0, t2; \
|
||||||
|
ADCQ $0, t3; \
|
||||||
|
\
|
||||||
|
MOVQ t0, h0; \
|
||||||
|
MOVQ t1, h1; \
|
||||||
|
MOVQ t2, h2; \
|
||||||
|
ANDQ $3, h2; \
|
||||||
|
MOVQ t2, t0; \
|
||||||
|
ANDQ $0xFFFFFFFFFFFFFFFC, t0; \
|
||||||
|
ADDQ t0, h0; \
|
||||||
|
ADCQ t3, h1; \
|
||||||
|
ADCQ $0, h2; \
|
||||||
|
SHRQ $2, t3, t2; \
|
||||||
|
SHRQ $2, t3; \
|
||||||
|
ADDQ t2, h0; \
|
||||||
|
ADCQ t3, h1; \
|
||||||
|
ADCQ $0, h2
|
||||||
|
|
||||||
|
// func update(state *[7]uint64, msg []byte)
|
||||||
|
TEXT ·update(SB), $0-32
|
||||||
|
MOVQ state+0(FP), DI
|
||||||
|
MOVQ msg_base+8(FP), SI
|
||||||
|
MOVQ msg_len+16(FP), R15
|
||||||
|
|
||||||
|
MOVQ 0(DI), R8 // h0
|
||||||
|
MOVQ 8(DI), R9 // h1
|
||||||
|
MOVQ 16(DI), R10 // h2
|
||||||
|
MOVQ 24(DI), R11 // r0
|
||||||
|
MOVQ 32(DI), R12 // r1
|
||||||
|
|
||||||
|
CMPQ R15, $16
|
||||||
|
JB bytes_between_0_and_15
|
||||||
|
|
||||||
|
loop:
|
||||||
|
POLY1305_ADD(SI, R8, R9, R10)
|
||||||
|
|
||||||
|
multiply:
|
||||||
|
POLY1305_MUL(R8, R9, R10, R11, R12, BX, CX, R13, R14)
|
||||||
|
SUBQ $16, R15
|
||||||
|
CMPQ R15, $16
|
||||||
|
JAE loop
|
||||||
|
|
||||||
|
bytes_between_0_and_15:
|
||||||
|
TESTQ R15, R15
|
||||||
|
JZ done
|
||||||
|
MOVQ $1, BX
|
||||||
|
XORQ CX, CX
|
||||||
|
XORQ R13, R13
|
||||||
|
ADDQ R15, SI
|
||||||
|
|
||||||
|
flush_buffer:
|
||||||
|
SHLQ $8, BX, CX
|
||||||
|
SHLQ $8, BX
|
||||||
|
MOVB -1(SI), R13
|
||||||
|
XORQ R13, BX
|
||||||
|
DECQ SI
|
||||||
|
DECQ R15
|
||||||
|
JNZ flush_buffer
|
||||||
|
|
||||||
|
ADDQ BX, R8
|
||||||
|
ADCQ CX, R9
|
||||||
|
ADCQ $0, R10
|
||||||
|
MOVQ $16, R15
|
||||||
|
JMP multiply
|
||||||
|
|
||||||
|
done:
|
||||||
|
MOVQ R8, 0(DI)
|
||||||
|
MOVQ R9, 8(DI)
|
||||||
|
MOVQ R10, 16(DI)
|
||||||
|
RET
|
310
vendor/golang.org/x/crypto/internal/poly1305/sum_generic.go
generated
vendored
Normal file
310
vendor/golang.org/x/crypto/internal/poly1305/sum_generic.go
generated
vendored
Normal file
|
@ -0,0 +1,310 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
// This file provides the generic implementation of Sum and MAC. Other files
|
||||||
|
// might provide optimized assembly implementations of some of this code.
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
import "encoding/binary"
|
||||||
|
|
||||||
|
// Poly1305 [RFC 7539] is a relatively simple algorithm: the authentication tag
|
||||||
|
// for a 64 bytes message is approximately
|
||||||
|
//
|
||||||
|
// s + m[0:16] * r⁴ + m[16:32] * r³ + m[32:48] * r² + m[48:64] * r mod 2¹³⁰ - 5
|
||||||
|
//
|
||||||
|
// for some secret r and s. It can be computed sequentially like
|
||||||
|
//
|
||||||
|
// for len(msg) > 0:
|
||||||
|
// h += read(msg, 16)
|
||||||
|
// h *= r
|
||||||
|
// h %= 2¹³⁰ - 5
|
||||||
|
// return h + s
|
||||||
|
//
|
||||||
|
// All the complexity is about doing performant constant-time math on numbers
|
||||||
|
// larger than any available numeric type.
|
||||||
|
|
||||||
|
func sumGeneric(out *[TagSize]byte, msg []byte, key *[32]byte) {
|
||||||
|
h := newMACGeneric(key)
|
||||||
|
h.Write(msg)
|
||||||
|
h.Sum(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMACGeneric(key *[32]byte) macGeneric {
|
||||||
|
m := macGeneric{}
|
||||||
|
initialize(key, &m.macState)
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
// macState holds numbers in saturated 64-bit little-endian limbs. That is,
|
||||||
|
// the value of [x0, x1, x2] is x[0] + x[1] * 2⁶⁴ + x[2] * 2¹²⁸.
|
||||||
|
type macState struct {
|
||||||
|
// h is the main accumulator. It is to be interpreted modulo 2¹³⁰ - 5, but
|
||||||
|
// can grow larger during and after rounds. It must, however, remain below
|
||||||
|
// 2 * (2¹³⁰ - 5).
|
||||||
|
h [3]uint64
|
||||||
|
// r and s are the private key components.
|
||||||
|
r [2]uint64
|
||||||
|
s [2]uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type macGeneric struct {
|
||||||
|
macState
|
||||||
|
|
||||||
|
buffer [TagSize]byte
|
||||||
|
offset int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write splits the incoming message into TagSize chunks, and passes them to
|
||||||
|
// update. It buffers incomplete chunks.
|
||||||
|
func (h *macGeneric) Write(p []byte) (int, error) {
|
||||||
|
nn := len(p)
|
||||||
|
if h.offset > 0 {
|
||||||
|
n := copy(h.buffer[h.offset:], p)
|
||||||
|
if h.offset+n < TagSize {
|
||||||
|
h.offset += n
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
p = p[n:]
|
||||||
|
h.offset = 0
|
||||||
|
updateGeneric(&h.macState, h.buffer[:])
|
||||||
|
}
|
||||||
|
if n := len(p) - (len(p) % TagSize); n > 0 {
|
||||||
|
updateGeneric(&h.macState, p[:n])
|
||||||
|
p = p[n:]
|
||||||
|
}
|
||||||
|
if len(p) > 0 {
|
||||||
|
h.offset += copy(h.buffer[h.offset:], p)
|
||||||
|
}
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum flushes the last incomplete chunk from the buffer, if any, and generates
|
||||||
|
// the MAC output. It does not modify its state, in order to allow for multiple
|
||||||
|
// calls to Sum, even if no Write is allowed after Sum.
|
||||||
|
func (h *macGeneric) Sum(out *[TagSize]byte) {
|
||||||
|
state := h.macState
|
||||||
|
if h.offset > 0 {
|
||||||
|
updateGeneric(&state, h.buffer[:h.offset])
|
||||||
|
}
|
||||||
|
finalize(out, &state.h, &state.s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// [rMask0, rMask1] is the specified Poly1305 clamping mask in little-endian. It
|
||||||
|
// clears some bits of the secret coefficient to make it possible to implement
|
||||||
|
// multiplication more efficiently.
|
||||||
|
const (
|
||||||
|
rMask0 = 0x0FFFFFFC0FFFFFFF
|
||||||
|
rMask1 = 0x0FFFFFFC0FFFFFFC
|
||||||
|
)
|
||||||
|
|
||||||
|
// initialize loads the 256-bit key into the two 128-bit secret values r and s.
|
||||||
|
func initialize(key *[32]byte, m *macState) {
|
||||||
|
m.r[0] = binary.LittleEndian.Uint64(key[0:8]) & rMask0
|
||||||
|
m.r[1] = binary.LittleEndian.Uint64(key[8:16]) & rMask1
|
||||||
|
m.s[0] = binary.LittleEndian.Uint64(key[16:24])
|
||||||
|
m.s[1] = binary.LittleEndian.Uint64(key[24:32])
|
||||||
|
}
|
||||||
|
|
||||||
|
// uint128 holds a 128-bit number as two 64-bit limbs, for use with the
|
||||||
|
// bits.Mul64 and bits.Add64 intrinsics.
|
||||||
|
type uint128 struct {
|
||||||
|
lo, hi uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func mul64(a, b uint64) uint128 {
|
||||||
|
hi, lo := bitsMul64(a, b)
|
||||||
|
return uint128{lo, hi}
|
||||||
|
}
|
||||||
|
|
||||||
|
func add128(a, b uint128) uint128 {
|
||||||
|
lo, c := bitsAdd64(a.lo, b.lo, 0)
|
||||||
|
hi, c := bitsAdd64(a.hi, b.hi, c)
|
||||||
|
if c != 0 {
|
||||||
|
panic("poly1305: unexpected overflow")
|
||||||
|
}
|
||||||
|
return uint128{lo, hi}
|
||||||
|
}
|
||||||
|
|
||||||
|
func shiftRightBy2(a uint128) uint128 {
|
||||||
|
a.lo = a.lo>>2 | (a.hi&3)<<62
|
||||||
|
a.hi = a.hi >> 2
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
// updateGeneric absorbs msg into the state.h accumulator. For each chunk m of
|
||||||
|
// 128 bits of message, it computes
|
||||||
|
//
|
||||||
|
// h₊ = (h + m) * r mod 2¹³⁰ - 5
|
||||||
|
//
|
||||||
|
// If the msg length is not a multiple of TagSize, it assumes the last
|
||||||
|
// incomplete chunk is the final one.
|
||||||
|
func updateGeneric(state *macState, msg []byte) {
|
||||||
|
h0, h1, h2 := state.h[0], state.h[1], state.h[2]
|
||||||
|
r0, r1 := state.r[0], state.r[1]
|
||||||
|
|
||||||
|
for len(msg) > 0 {
|
||||||
|
var c uint64
|
||||||
|
|
||||||
|
// For the first step, h + m, we use a chain of bits.Add64 intrinsics.
|
||||||
|
// The resulting value of h might exceed 2¹³⁰ - 5, but will be partially
|
||||||
|
// reduced at the end of the multiplication below.
|
||||||
|
//
|
||||||
|
// The spec requires us to set a bit just above the message size, not to
|
||||||
|
// hide leading zeroes. For full chunks, that's 1 << 128, so we can just
|
||||||
|
// add 1 to the most significant (2¹²⁸) limb, h2.
|
||||||
|
if len(msg) >= TagSize {
|
||||||
|
h0, c = bitsAdd64(h0, binary.LittleEndian.Uint64(msg[0:8]), 0)
|
||||||
|
h1, c = bitsAdd64(h1, binary.LittleEndian.Uint64(msg[8:16]), c)
|
||||||
|
h2 += c + 1
|
||||||
|
|
||||||
|
msg = msg[TagSize:]
|
||||||
|
} else {
|
||||||
|
var buf [TagSize]byte
|
||||||
|
copy(buf[:], msg)
|
||||||
|
buf[len(msg)] = 1
|
||||||
|
|
||||||
|
h0, c = bitsAdd64(h0, binary.LittleEndian.Uint64(buf[0:8]), 0)
|
||||||
|
h1, c = bitsAdd64(h1, binary.LittleEndian.Uint64(buf[8:16]), c)
|
||||||
|
h2 += c
|
||||||
|
|
||||||
|
msg = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiplication of big number limbs is similar to elementary school
|
||||||
|
// columnar multiplication. Instead of digits, there are 64-bit limbs.
|
||||||
|
//
|
||||||
|
// We are multiplying a 3 limbs number, h, by a 2 limbs number, r.
|
||||||
|
//
|
||||||
|
// h2 h1 h0 x
|
||||||
|
// r1 r0 =
|
||||||
|
// ----------------
|
||||||
|
// h2r0 h1r0 h0r0 <-- individual 128-bit products
|
||||||
|
// + h2r1 h1r1 h0r1
|
||||||
|
// ------------------------
|
||||||
|
// m3 m2 m1 m0 <-- result in 128-bit overlapping limbs
|
||||||
|
// ------------------------
|
||||||
|
// m3.hi m2.hi m1.hi m0.hi <-- carry propagation
|
||||||
|
// + m3.lo m2.lo m1.lo m0.lo
|
||||||
|
// -------------------------------
|
||||||
|
// t4 t3 t2 t1 t0 <-- final result in 64-bit limbs
|
||||||
|
//
|
||||||
|
// The main difference from pen-and-paper multiplication is that we do
|
||||||
|
// carry propagation in a separate step, as if we wrote two digit sums
|
||||||
|
// at first (the 128-bit limbs), and then carried the tens all at once.
|
||||||
|
|
||||||
|
h0r0 := mul64(h0, r0)
|
||||||
|
h1r0 := mul64(h1, r0)
|
||||||
|
h2r0 := mul64(h2, r0)
|
||||||
|
h0r1 := mul64(h0, r1)
|
||||||
|
h1r1 := mul64(h1, r1)
|
||||||
|
h2r1 := mul64(h2, r1)
|
||||||
|
|
||||||
|
// Since h2 is known to be at most 7 (5 + 1 + 1), and r0 and r1 have their
|
||||||
|
// top 4 bits cleared by rMask{0,1}, we know that their product is not going
|
||||||
|
// to overflow 64 bits, so we can ignore the high part of the products.
|
||||||
|
//
|
||||||
|
// This also means that the product doesn't have a fifth limb (t4).
|
||||||
|
if h2r0.hi != 0 {
|
||||||
|
panic("poly1305: unexpected overflow")
|
||||||
|
}
|
||||||
|
if h2r1.hi != 0 {
|
||||||
|
panic("poly1305: unexpected overflow")
|
||||||
|
}
|
||||||
|
|
||||||
|
m0 := h0r0
|
||||||
|
m1 := add128(h1r0, h0r1) // These two additions don't overflow thanks again
|
||||||
|
m2 := add128(h2r0, h1r1) // to the 4 masked bits at the top of r0 and r1.
|
||||||
|
m3 := h2r1
|
||||||
|
|
||||||
|
t0 := m0.lo
|
||||||
|
t1, c := bitsAdd64(m1.lo, m0.hi, 0)
|
||||||
|
t2, c := bitsAdd64(m2.lo, m1.hi, c)
|
||||||
|
t3, _ := bitsAdd64(m3.lo, m2.hi, c)
|
||||||
|
|
||||||
|
// Now we have the result as 4 64-bit limbs, and we need to reduce it
|
||||||
|
// modulo 2¹³⁰ - 5. The special shape of this Crandall prime lets us do
|
||||||
|
// a cheap partial reduction according to the reduction identity
|
||||||
|
//
|
||||||
|
// c * 2¹³⁰ + n = c * 5 + n mod 2¹³⁰ - 5
|
||||||
|
//
|
||||||
|
// because 2¹³⁰ = 5 mod 2¹³⁰ - 5. Partial reduction since the result is
|
||||||
|
// likely to be larger than 2¹³⁰ - 5, but still small enough to fit the
|
||||||
|
// assumptions we make about h in the rest of the code.
|
||||||
|
//
|
||||||
|
// See also https://speakerdeck.com/gtank/engineering-prime-numbers?slide=23
|
||||||
|
|
||||||
|
// We split the final result at the 2¹³⁰ mark into h and cc, the carry.
|
||||||
|
// Note that the carry bits are effectively shifted left by 2, in other
|
||||||
|
// words, cc = c * 4 for the c in the reduction identity.
|
||||||
|
h0, h1, h2 = t0, t1, t2&maskLow2Bits
|
||||||
|
cc := uint128{t2 & maskNotLow2Bits, t3}
|
||||||
|
|
||||||
|
// To add c * 5 to h, we first add cc = c * 4, and then add (cc >> 2) = c.
|
||||||
|
|
||||||
|
h0, c = bitsAdd64(h0, cc.lo, 0)
|
||||||
|
h1, c = bitsAdd64(h1, cc.hi, c)
|
||||||
|
h2 += c
|
||||||
|
|
||||||
|
cc = shiftRightBy2(cc)
|
||||||
|
|
||||||
|
h0, c = bitsAdd64(h0, cc.lo, 0)
|
||||||
|
h1, c = bitsAdd64(h1, cc.hi, c)
|
||||||
|
h2 += c
|
||||||
|
|
||||||
|
// h2 is at most 3 + 1 + 1 = 5, making the whole of h at most
|
||||||
|
//
|
||||||
|
// 5 * 2¹²⁸ + (2¹²⁸ - 1) = 6 * 2¹²⁸ - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
state.h[0], state.h[1], state.h[2] = h0, h1, h2
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
maskLow2Bits uint64 = 0x0000000000000003
|
||||||
|
maskNotLow2Bits uint64 = ^maskLow2Bits
|
||||||
|
)
|
||||||
|
|
||||||
|
// select64 returns x if v == 1 and y if v == 0, in constant time.
|
||||||
|
func select64(v, x, y uint64) uint64 { return ^(v-1)&x | (v-1)&y }
|
||||||
|
|
||||||
|
// [p0, p1, p2] is 2¹³⁰ - 5 in little endian order.
|
||||||
|
const (
|
||||||
|
p0 = 0xFFFFFFFFFFFFFFFB
|
||||||
|
p1 = 0xFFFFFFFFFFFFFFFF
|
||||||
|
p2 = 0x0000000000000003
|
||||||
|
)
|
||||||
|
|
||||||
|
// finalize completes the modular reduction of h and computes
|
||||||
|
//
|
||||||
|
// out = h + s mod 2¹²⁸
|
||||||
|
//
|
||||||
|
func finalize(out *[TagSize]byte, h *[3]uint64, s *[2]uint64) {
|
||||||
|
h0, h1, h2 := h[0], h[1], h[2]
|
||||||
|
|
||||||
|
// After the partial reduction in updateGeneric, h might be more than
|
||||||
|
// 2¹³⁰ - 5, but will be less than 2 * (2¹³⁰ - 5). To complete the reduction
|
||||||
|
// in constant time, we compute t = h - (2¹³⁰ - 5), and select h as the
|
||||||
|
// result if the subtraction underflows, and t otherwise.
|
||||||
|
|
||||||
|
hMinusP0, b := bitsSub64(h0, p0, 0)
|
||||||
|
hMinusP1, b := bitsSub64(h1, p1, b)
|
||||||
|
_, b = bitsSub64(h2, p2, b)
|
||||||
|
|
||||||
|
// h = h if h < p else h - p
|
||||||
|
h0 = select64(b, h0, hMinusP0)
|
||||||
|
h1 = select64(b, h1, hMinusP1)
|
||||||
|
|
||||||
|
// Finally, we compute the last Poly1305 step
|
||||||
|
//
|
||||||
|
// tag = h + s mod 2¹²⁸
|
||||||
|
//
|
||||||
|
// by just doing a wide addition with the 128 low bits of h and discarding
|
||||||
|
// the overflow.
|
||||||
|
h0, c := bitsAdd64(h0, s[0], 0)
|
||||||
|
h1, _ = bitsAdd64(h1, s[1], c)
|
||||||
|
|
||||||
|
binary.LittleEndian.PutUint64(out[0:8], h0)
|
||||||
|
binary.LittleEndian.PutUint64(out[8:16], h1)
|
||||||
|
}
|
48
vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go
generated
vendored
Normal file
48
vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func update(state *macState, msg []byte)
|
||||||
|
|
||||||
|
// mac is a wrapper for macGeneric that redirects calls that would have gone to
|
||||||
|
// updateGeneric to update.
|
||||||
|
//
|
||||||
|
// Its Write and Sum methods are otherwise identical to the macGeneric ones, but
|
||||||
|
// using function pointers would carry a major performance cost.
|
||||||
|
type mac struct{ macGeneric }
|
||||||
|
|
||||||
|
func (h *mac) Write(p []byte) (int, error) {
|
||||||
|
nn := len(p)
|
||||||
|
if h.offset > 0 {
|
||||||
|
n := copy(h.buffer[h.offset:], p)
|
||||||
|
if h.offset+n < TagSize {
|
||||||
|
h.offset += n
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
p = p[n:]
|
||||||
|
h.offset = 0
|
||||||
|
update(&h.macState, h.buffer[:])
|
||||||
|
}
|
||||||
|
if n := len(p) - (len(p) % TagSize); n > 0 {
|
||||||
|
update(&h.macState, p[:n])
|
||||||
|
p = p[n:]
|
||||||
|
}
|
||||||
|
if len(p) > 0 {
|
||||||
|
h.offset += copy(h.buffer[h.offset:], p)
|
||||||
|
}
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *mac) Sum(out *[16]byte) {
|
||||||
|
state := h.macState
|
||||||
|
if h.offset > 0 {
|
||||||
|
update(&state, h.buffer[:h.offset])
|
||||||
|
}
|
||||||
|
finalize(out, &state.h, &state.s)
|
||||||
|
}
|
182
vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.s
generated
vendored
Normal file
182
vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.s
generated
vendored
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// This was ported from the amd64 implementation.
|
||||||
|
|
||||||
|
#define POLY1305_ADD(msg, h0, h1, h2, t0, t1, t2) \
|
||||||
|
MOVD (msg), t0; \
|
||||||
|
MOVD 8(msg), t1; \
|
||||||
|
MOVD $1, t2; \
|
||||||
|
ADDC t0, h0, h0; \
|
||||||
|
ADDE t1, h1, h1; \
|
||||||
|
ADDE t2, h2; \
|
||||||
|
ADD $16, msg
|
||||||
|
|
||||||
|
#define POLY1305_MUL(h0, h1, h2, r0, r1, t0, t1, t2, t3, t4, t5) \
|
||||||
|
MULLD r0, h0, t0; \
|
||||||
|
MULLD r0, h1, t4; \
|
||||||
|
MULHDU r0, h0, t1; \
|
||||||
|
MULHDU r0, h1, t5; \
|
||||||
|
ADDC t4, t1, t1; \
|
||||||
|
MULLD r0, h2, t2; \
|
||||||
|
ADDZE t5; \
|
||||||
|
MULHDU r1, h0, t4; \
|
||||||
|
MULLD r1, h0, h0; \
|
||||||
|
ADD t5, t2, t2; \
|
||||||
|
ADDC h0, t1, t1; \
|
||||||
|
MULLD h2, r1, t3; \
|
||||||
|
ADDZE t4, h0; \
|
||||||
|
MULHDU r1, h1, t5; \
|
||||||
|
MULLD r1, h1, t4; \
|
||||||
|
ADDC t4, t2, t2; \
|
||||||
|
ADDE t5, t3, t3; \
|
||||||
|
ADDC h0, t2, t2; \
|
||||||
|
MOVD $-4, t4; \
|
||||||
|
MOVD t0, h0; \
|
||||||
|
MOVD t1, h1; \
|
||||||
|
ADDZE t3; \
|
||||||
|
ANDCC $3, t2, h2; \
|
||||||
|
AND t2, t4, t0; \
|
||||||
|
ADDC t0, h0, h0; \
|
||||||
|
ADDE t3, h1, h1; \
|
||||||
|
SLD $62, t3, t4; \
|
||||||
|
SRD $2, t2; \
|
||||||
|
ADDZE h2; \
|
||||||
|
OR t4, t2, t2; \
|
||||||
|
SRD $2, t3; \
|
||||||
|
ADDC t2, h0, h0; \
|
||||||
|
ADDE t3, h1, h1; \
|
||||||
|
ADDZE h2
|
||||||
|
|
||||||
|
DATA ·poly1305Mask<>+0x00(SB)/8, $0x0FFFFFFC0FFFFFFF
|
||||||
|
DATA ·poly1305Mask<>+0x08(SB)/8, $0x0FFFFFFC0FFFFFFC
|
||||||
|
GLOBL ·poly1305Mask<>(SB), RODATA, $16
|
||||||
|
|
||||||
|
// func update(state *[7]uint64, msg []byte)
|
||||||
|
TEXT ·update(SB), $0-32
|
||||||
|
MOVD state+0(FP), R3
|
||||||
|
MOVD msg_base+8(FP), R4
|
||||||
|
MOVD msg_len+16(FP), R5
|
||||||
|
|
||||||
|
MOVD 0(R3), R8 // h0
|
||||||
|
MOVD 8(R3), R9 // h1
|
||||||
|
MOVD 16(R3), R10 // h2
|
||||||
|
MOVD 24(R3), R11 // r0
|
||||||
|
MOVD 32(R3), R12 // r1
|
||||||
|
|
||||||
|
CMP R5, $16
|
||||||
|
BLT bytes_between_0_and_15
|
||||||
|
|
||||||
|
loop:
|
||||||
|
POLY1305_ADD(R4, R8, R9, R10, R20, R21, R22)
|
||||||
|
|
||||||
|
multiply:
|
||||||
|
POLY1305_MUL(R8, R9, R10, R11, R12, R16, R17, R18, R14, R20, R21)
|
||||||
|
ADD $-16, R5
|
||||||
|
CMP R5, $16
|
||||||
|
BGE loop
|
||||||
|
|
||||||
|
bytes_between_0_and_15:
|
||||||
|
CMP R5, $0
|
||||||
|
BEQ done
|
||||||
|
MOVD $0, R16 // h0
|
||||||
|
MOVD $0, R17 // h1
|
||||||
|
|
||||||
|
flush_buffer:
|
||||||
|
CMP R5, $8
|
||||||
|
BLE just1
|
||||||
|
|
||||||
|
MOVD $8, R21
|
||||||
|
SUB R21, R5, R21
|
||||||
|
|
||||||
|
// Greater than 8 -- load the rightmost remaining bytes in msg
|
||||||
|
// and put into R17 (h1)
|
||||||
|
MOVD (R4)(R21), R17
|
||||||
|
MOVD $16, R22
|
||||||
|
|
||||||
|
// Find the offset to those bytes
|
||||||
|
SUB R5, R22, R22
|
||||||
|
SLD $3, R22
|
||||||
|
|
||||||
|
// Shift to get only the bytes in msg
|
||||||
|
SRD R22, R17, R17
|
||||||
|
|
||||||
|
// Put 1 at high end
|
||||||
|
MOVD $1, R23
|
||||||
|
SLD $3, R21
|
||||||
|
SLD R21, R23, R23
|
||||||
|
OR R23, R17, R17
|
||||||
|
|
||||||
|
// Remainder is 8
|
||||||
|
MOVD $8, R5
|
||||||
|
|
||||||
|
just1:
|
||||||
|
CMP R5, $8
|
||||||
|
BLT less8
|
||||||
|
|
||||||
|
// Exactly 8
|
||||||
|
MOVD (R4), R16
|
||||||
|
|
||||||
|
CMP R17, $0
|
||||||
|
|
||||||
|
// Check if we've already set R17; if not
|
||||||
|
// set 1 to indicate end of msg.
|
||||||
|
BNE carry
|
||||||
|
MOVD $1, R17
|
||||||
|
BR carry
|
||||||
|
|
||||||
|
less8:
|
||||||
|
MOVD $0, R16 // h0
|
||||||
|
MOVD $0, R22 // shift count
|
||||||
|
CMP R5, $4
|
||||||
|
BLT less4
|
||||||
|
MOVWZ (R4), R16
|
||||||
|
ADD $4, R4
|
||||||
|
ADD $-4, R5
|
||||||
|
MOVD $32, R22
|
||||||
|
|
||||||
|
less4:
|
||||||
|
CMP R5, $2
|
||||||
|
BLT less2
|
||||||
|
MOVHZ (R4), R21
|
||||||
|
SLD R22, R21, R21
|
||||||
|
OR R16, R21, R16
|
||||||
|
ADD $16, R22
|
||||||
|
ADD $-2, R5
|
||||||
|
ADD $2, R4
|
||||||
|
|
||||||
|
less2:
|
||||||
|
CMP R5, $0
|
||||||
|
BEQ insert1
|
||||||
|
MOVBZ (R4), R21
|
||||||
|
SLD R22, R21, R21
|
||||||
|
OR R16, R21, R16
|
||||||
|
ADD $8, R22
|
||||||
|
|
||||||
|
insert1:
|
||||||
|
// Insert 1 at end of msg
|
||||||
|
MOVD $1, R21
|
||||||
|
SLD R22, R21, R21
|
||||||
|
OR R16, R21, R16
|
||||||
|
|
||||||
|
carry:
|
||||||
|
// Add new values to h0, h1, h2
|
||||||
|
ADDC R16, R8
|
||||||
|
ADDE R17, R9
|
||||||
|
ADDZE R10, R10
|
||||||
|
MOVD $16, R5
|
||||||
|
ADD R5, R4
|
||||||
|
BR multiply
|
||||||
|
|
||||||
|
done:
|
||||||
|
// Save h0, h1, h2 in state
|
||||||
|
MOVD R8, 0(R3)
|
||||||
|
MOVD R9, 8(R3)
|
||||||
|
MOVD R10, 16(R3)
|
||||||
|
RET
|
76
vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go
generated
vendored
Normal file
76
vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
|
package poly1305
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/cpu"
|
||||||
|
)
|
||||||
|
|
||||||
|
// updateVX is an assembly implementation of Poly1305 that uses vector
|
||||||
|
// instructions. It must only be called if the vector facility (vx) is
|
||||||
|
// available.
|
||||||
|
//go:noescape
|
||||||
|
func updateVX(state *macState, msg []byte)
|
||||||
|
|
||||||
|
// mac is a replacement for macGeneric that uses a larger buffer and redirects
|
||||||
|
// calls that would have gone to updateGeneric to updateVX if the vector
|
||||||
|
// facility is installed.
|
||||||
|
//
|
||||||
|
// A larger buffer is required for good performance because the vector
|
||||||
|
// implementation has a higher fixed cost per call than the generic
|
||||||
|
// implementation.
|
||||||
|
type mac struct {
|
||||||
|
macState
|
||||||
|
|
||||||
|
buffer [16 * TagSize]byte // size must be a multiple of block size (16)
|
||||||
|
offset int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *mac) Write(p []byte) (int, error) {
|
||||||
|
nn := len(p)
|
||||||
|
if h.offset > 0 {
|
||||||
|
n := copy(h.buffer[h.offset:], p)
|
||||||
|
if h.offset+n < len(h.buffer) {
|
||||||
|
h.offset += n
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
p = p[n:]
|
||||||
|
h.offset = 0
|
||||||
|
if cpu.S390X.HasVX {
|
||||||
|
updateVX(&h.macState, h.buffer[:])
|
||||||
|
} else {
|
||||||
|
updateGeneric(&h.macState, h.buffer[:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tail := len(p) % len(h.buffer) // number of bytes to copy into buffer
|
||||||
|
body := len(p) - tail // number of bytes to process now
|
||||||
|
if body > 0 {
|
||||||
|
if cpu.S390X.HasVX {
|
||||||
|
updateVX(&h.macState, p[:body])
|
||||||
|
} else {
|
||||||
|
updateGeneric(&h.macState, p[:body])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h.offset = copy(h.buffer[:], p[body:]) // copy tail bytes - can be 0
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *mac) Sum(out *[TagSize]byte) {
|
||||||
|
state := h.macState
|
||||||
|
remainder := h.buffer[:h.offset]
|
||||||
|
|
||||||
|
// Use the generic implementation if we have 2 or fewer blocks left
|
||||||
|
// to sum. The vector implementation has a higher startup time.
|
||||||
|
if cpu.S390X.HasVX && len(remainder) > 2*TagSize {
|
||||||
|
updateVX(&state, remainder)
|
||||||
|
} else if len(remainder) > 0 {
|
||||||
|
updateGeneric(&state, remainder)
|
||||||
|
}
|
||||||
|
finalize(out, &state.h, &state.s)
|
||||||
|
}
|
504
vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s
generated
vendored
Normal file
504
vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s
generated
vendored
Normal file
|
@ -0,0 +1,504 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// This implementation of Poly1305 uses the vector facility (vx)
|
||||||
|
// to process up to 2 blocks (32 bytes) per iteration using an
|
||||||
|
// algorithm based on the one described in:
|
||||||
|
//
|
||||||
|
// NEON crypto, Daniel J. Bernstein & Peter Schwabe
|
||||||
|
// https://cryptojedi.org/papers/neoncrypto-20120320.pdf
|
||||||
|
//
|
||||||
|
// This algorithm uses 5 26-bit limbs to represent a 130-bit
|
||||||
|
// value. These limbs are, for the most part, zero extended and
|
||||||
|
// placed into 64-bit vector register elements. Each vector
|
||||||
|
// register is 128-bits wide and so holds 2 of these elements.
|
||||||
|
// Using 26-bit limbs allows us plenty of headroom to accommodate
|
||||||
|
// accumulations before and after multiplication without
|
||||||
|
// overflowing either 32-bits (before multiplication) or 64-bits
|
||||||
|
// (after multiplication).
|
||||||
|
//
|
||||||
|
// In order to parallelise the operations required to calculate
|
||||||
|
// the sum we use two separate accumulators and then sum those
|
||||||
|
// in an extra final step. For compatibility with the generic
|
||||||
|
// implementation we perform this summation at the end of every
|
||||||
|
// updateVX call.
|
||||||
|
//
|
||||||
|
// To use two accumulators we must multiply the message blocks
|
||||||
|
// by r² rather than r. Only the final message block should be
|
||||||
|
// multiplied by r.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// We want to calculate the sum (h) for a 64 byte message (m):
|
||||||
|
//
|
||||||
|
// h = m[0:16]r⁴ + m[16:32]r³ + m[32:48]r² + m[48:64]r
|
||||||
|
//
|
||||||
|
// To do this we split the calculation into the even indices
|
||||||
|
// and odd indices of the message. These form our SIMD 'lanes':
|
||||||
|
//
|
||||||
|
// h = m[ 0:16]r⁴ + m[32:48]r² + <- lane 0
|
||||||
|
// m[16:32]r³ + m[48:64]r <- lane 1
|
||||||
|
//
|
||||||
|
// To calculate this iteratively we refactor so that both lanes
|
||||||
|
// are written in terms of r² and r:
|
||||||
|
//
|
||||||
|
// h = (m[ 0:16]r² + m[32:48])r² + <- lane 0
|
||||||
|
// (m[16:32]r² + m[48:64])r <- lane 1
|
||||||
|
// ^ ^
|
||||||
|
// | coefficients for second iteration
|
||||||
|
// coefficients for first iteration
|
||||||
|
//
|
||||||
|
// So in this case we would have two iterations. In the first
|
||||||
|
// both lanes are multiplied by r². In the second only the
|
||||||
|
// first lane is multiplied by r² and the second lane is
|
||||||
|
// instead multiplied by r. This gives use the odd and even
|
||||||
|
// powers of r that we need from the original equation.
|
||||||
|
//
|
||||||
|
// Notation:
|
||||||
|
//
|
||||||
|
// h - accumulator
|
||||||
|
// r - key
|
||||||
|
// m - message
|
||||||
|
//
|
||||||
|
// [a, b] - SIMD register holding two 64-bit values
|
||||||
|
// [a, b, c, d] - SIMD register holding four 32-bit values
|
||||||
|
// xᵢ[n] - limb n of variable x with bit width i
|
||||||
|
//
|
||||||
|
// Limbs are expressed in little endian order, so for 26-bit
|
||||||
|
// limbs x₂₆[4] will be the most significant limb and x₂₆[0]
|
||||||
|
// will be the least significant limb.
|
||||||
|
|
||||||
|
// masking constants
|
||||||
|
#define MOD24 V0 // [0x0000000000ffffff, 0x0000000000ffffff] - mask low 24-bits
|
||||||
|
#define MOD26 V1 // [0x0000000003ffffff, 0x0000000003ffffff] - mask low 26-bits
|
||||||
|
|
||||||
|
// expansion constants (see EXPAND macro)
|
||||||
|
#define EX0 V2
|
||||||
|
#define EX1 V3
|
||||||
|
#define EX2 V4
|
||||||
|
|
||||||
|
// key (r², r or 1 depending on context)
|
||||||
|
#define R_0 V5
|
||||||
|
#define R_1 V6
|
||||||
|
#define R_2 V7
|
||||||
|
#define R_3 V8
|
||||||
|
#define R_4 V9
|
||||||
|
|
||||||
|
// precalculated coefficients (5r², 5r or 0 depending on context)
|
||||||
|
#define R5_1 V10
|
||||||
|
#define R5_2 V11
|
||||||
|
#define R5_3 V12
|
||||||
|
#define R5_4 V13
|
||||||
|
|
||||||
|
// message block (m)
|
||||||
|
#define M_0 V14
|
||||||
|
#define M_1 V15
|
||||||
|
#define M_2 V16
|
||||||
|
#define M_3 V17
|
||||||
|
#define M_4 V18
|
||||||
|
|
||||||
|
// accumulator (h)
|
||||||
|
#define H_0 V19
|
||||||
|
#define H_1 V20
|
||||||
|
#define H_2 V21
|
||||||
|
#define H_3 V22
|
||||||
|
#define H_4 V23
|
||||||
|
|
||||||
|
// temporary registers (for short-lived values)
|
||||||
|
#define T_0 V24
|
||||||
|
#define T_1 V25
|
||||||
|
#define T_2 V26
|
||||||
|
#define T_3 V27
|
||||||
|
#define T_4 V28
|
||||||
|
|
||||||
|
GLOBL ·constants<>(SB), RODATA, $0x30
|
||||||
|
// EX0
|
||||||
|
DATA ·constants<>+0x00(SB)/8, $0x0006050403020100
|
||||||
|
DATA ·constants<>+0x08(SB)/8, $0x1016151413121110
|
||||||
|
// EX1
|
||||||
|
DATA ·constants<>+0x10(SB)/8, $0x060c0b0a09080706
|
||||||
|
DATA ·constants<>+0x18(SB)/8, $0x161c1b1a19181716
|
||||||
|
// EX2
|
||||||
|
DATA ·constants<>+0x20(SB)/8, $0x0d0d0d0d0d0f0e0d
|
||||||
|
DATA ·constants<>+0x28(SB)/8, $0x1d1d1d1d1d1f1e1d
|
||||||
|
|
||||||
|
// MULTIPLY multiplies each lane of f and g, partially reduced
|
||||||
|
// modulo 2¹³⁰ - 5. The result, h, consists of partial products
|
||||||
|
// in each lane that need to be reduced further to produce the
|
||||||
|
// final result.
|
||||||
|
//
|
||||||
|
// h₁₃₀ = (f₁₃₀g₁₃₀) % 2¹³⁰ + (5f₁₃₀g₁₃₀) / 2¹³⁰
|
||||||
|
//
|
||||||
|
// Note that the multiplication by 5 of the high bits is
|
||||||
|
// achieved by precalculating the multiplication of four of the
|
||||||
|
// g coefficients by 5. These are g51-g54.
|
||||||
|
#define MULTIPLY(f0, f1, f2, f3, f4, g0, g1, g2, g3, g4, g51, g52, g53, g54, h0, h1, h2, h3, h4) \
|
||||||
|
VMLOF f0, g0, h0 \
|
||||||
|
VMLOF f0, g3, h3 \
|
||||||
|
VMLOF f0, g1, h1 \
|
||||||
|
VMLOF f0, g4, h4 \
|
||||||
|
VMLOF f0, g2, h2 \
|
||||||
|
VMLOF f1, g54, T_0 \
|
||||||
|
VMLOF f1, g2, T_3 \
|
||||||
|
VMLOF f1, g0, T_1 \
|
||||||
|
VMLOF f1, g3, T_4 \
|
||||||
|
VMLOF f1, g1, T_2 \
|
||||||
|
VMALOF f2, g53, h0, h0 \
|
||||||
|
VMALOF f2, g1, h3, h3 \
|
||||||
|
VMALOF f2, g54, h1, h1 \
|
||||||
|
VMALOF f2, g2, h4, h4 \
|
||||||
|
VMALOF f2, g0, h2, h2 \
|
||||||
|
VMALOF f3, g52, T_0, T_0 \
|
||||||
|
VMALOF f3, g0, T_3, T_3 \
|
||||||
|
VMALOF f3, g53, T_1, T_1 \
|
||||||
|
VMALOF f3, g1, T_4, T_4 \
|
||||||
|
VMALOF f3, g54, T_2, T_2 \
|
||||||
|
VMALOF f4, g51, h0, h0 \
|
||||||
|
VMALOF f4, g54, h3, h3 \
|
||||||
|
VMALOF f4, g52, h1, h1 \
|
||||||
|
VMALOF f4, g0, h4, h4 \
|
||||||
|
VMALOF f4, g53, h2, h2 \
|
||||||
|
VAG T_0, h0, h0 \
|
||||||
|
VAG T_3, h3, h3 \
|
||||||
|
VAG T_1, h1, h1 \
|
||||||
|
VAG T_4, h4, h4 \
|
||||||
|
VAG T_2, h2, h2
|
||||||
|
|
||||||
|
// REDUCE performs the following carry operations in four
|
||||||
|
// stages, as specified in Bernstein & Schwabe:
|
||||||
|
//
|
||||||
|
// 1: h₂₆[0]->h₂₆[1] h₂₆[3]->h₂₆[4]
|
||||||
|
// 2: h₂₆[1]->h₂₆[2] h₂₆[4]->h₂₆[0]
|
||||||
|
// 3: h₂₆[0]->h₂₆[1] h₂₆[2]->h₂₆[3]
|
||||||
|
// 4: h₂₆[3]->h₂₆[4]
|
||||||
|
//
|
||||||
|
// The result is that all of the limbs are limited to 26-bits
|
||||||
|
// except for h₂₆[1] and h₂₆[4] which are limited to 27-bits.
|
||||||
|
//
|
||||||
|
// Note that although each limb is aligned at 26-bit intervals
|
||||||
|
// they may contain values that exceed 2²⁶ - 1, hence the need
|
||||||
|
// to carry the excess bits in each limb.
|
||||||
|
#define REDUCE(h0, h1, h2, h3, h4) \
|
||||||
|
VESRLG $26, h0, T_0 \
|
||||||
|
VESRLG $26, h3, T_1 \
|
||||||
|
VN MOD26, h0, h0 \
|
||||||
|
VN MOD26, h3, h3 \
|
||||||
|
VAG T_0, h1, h1 \
|
||||||
|
VAG T_1, h4, h4 \
|
||||||
|
VESRLG $26, h1, T_2 \
|
||||||
|
VESRLG $26, h4, T_3 \
|
||||||
|
VN MOD26, h1, h1 \
|
||||||
|
VN MOD26, h4, h4 \
|
||||||
|
VESLG $2, T_3, T_4 \
|
||||||
|
VAG T_3, T_4, T_4 \
|
||||||
|
VAG T_2, h2, h2 \
|
||||||
|
VAG T_4, h0, h0 \
|
||||||
|
VESRLG $26, h2, T_0 \
|
||||||
|
VESRLG $26, h0, T_1 \
|
||||||
|
VN MOD26, h2, h2 \
|
||||||
|
VN MOD26, h0, h0 \
|
||||||
|
VAG T_0, h3, h3 \
|
||||||
|
VAG T_1, h1, h1 \
|
||||||
|
VESRLG $26, h3, T_2 \
|
||||||
|
VN MOD26, h3, h3 \
|
||||||
|
VAG T_2, h4, h4
|
||||||
|
|
||||||
|
// EXPAND splits the 128-bit little-endian values in0 and in1
|
||||||
|
// into 26-bit big-endian limbs and places the results into
|
||||||
|
// the first and second lane of d₂₆[0:4] respectively.
|
||||||
|
//
|
||||||
|
// The EX0, EX1 and EX2 constants are arrays of byte indices
|
||||||
|
// for permutation. The permutation both reverses the bytes
|
||||||
|
// in the input and ensures the bytes are copied into the
|
||||||
|
// destination limb ready to be shifted into their final
|
||||||
|
// position.
|
||||||
|
#define EXPAND(in0, in1, d0, d1, d2, d3, d4) \
|
||||||
|
VPERM in0, in1, EX0, d0 \
|
||||||
|
VPERM in0, in1, EX1, d2 \
|
||||||
|
VPERM in0, in1, EX2, d4 \
|
||||||
|
VESRLG $26, d0, d1 \
|
||||||
|
VESRLG $30, d2, d3 \
|
||||||
|
VESRLG $4, d2, d2 \
|
||||||
|
VN MOD26, d0, d0 \ // [in0₂₆[0], in1₂₆[0]]
|
||||||
|
VN MOD26, d3, d3 \ // [in0₂₆[3], in1₂₆[3]]
|
||||||
|
VN MOD26, d1, d1 \ // [in0₂₆[1], in1₂₆[1]]
|
||||||
|
VN MOD24, d4, d4 \ // [in0₂₆[4], in1₂₆[4]]
|
||||||
|
VN MOD26, d2, d2 // [in0₂₆[2], in1₂₆[2]]
|
||||||
|
|
||||||
|
// func updateVX(state *macState, msg []byte)
|
||||||
|
TEXT ·updateVX(SB), NOSPLIT, $0
|
||||||
|
MOVD state+0(FP), R1
|
||||||
|
LMG msg+8(FP), R2, R3 // R2=msg_base, R3=msg_len
|
||||||
|
|
||||||
|
// load EX0, EX1 and EX2
|
||||||
|
MOVD $·constants<>(SB), R5
|
||||||
|
VLM (R5), EX0, EX2
|
||||||
|
|
||||||
|
// generate masks
|
||||||
|
VGMG $(64-24), $63, MOD24 // [0x00ffffff, 0x00ffffff]
|
||||||
|
VGMG $(64-26), $63, MOD26 // [0x03ffffff, 0x03ffffff]
|
||||||
|
|
||||||
|
// load h (accumulator) and r (key) from state
|
||||||
|
VZERO T_1 // [0, 0]
|
||||||
|
VL 0(R1), T_0 // [h₆₄[0], h₆₄[1]]
|
||||||
|
VLEG $0, 16(R1), T_1 // [h₆₄[2], 0]
|
||||||
|
VL 24(R1), T_2 // [r₆₄[0], r₆₄[1]]
|
||||||
|
VPDI $0, T_0, T_2, T_3 // [h₆₄[0], r₆₄[0]]
|
||||||
|
VPDI $5, T_0, T_2, T_4 // [h₆₄[1], r₆₄[1]]
|
||||||
|
|
||||||
|
// unpack h and r into 26-bit limbs
|
||||||
|
// note: h₆₄[2] may have the low 3 bits set, so h₂₆[4] is a 27-bit value
|
||||||
|
VN MOD26, T_3, H_0 // [h₂₆[0], r₂₆[0]]
|
||||||
|
VZERO H_1 // [0, 0]
|
||||||
|
VZERO H_3 // [0, 0]
|
||||||
|
VGMG $(64-12-14), $(63-12), T_0 // [0x03fff000, 0x03fff000] - 26-bit mask with low 12 bits masked out
|
||||||
|
VESLG $24, T_1, T_1 // [h₆₄[2]<<24, 0]
|
||||||
|
VERIMG $-26&63, T_3, MOD26, H_1 // [h₂₆[1], r₂₆[1]]
|
||||||
|
VESRLG $+52&63, T_3, H_2 // [h₂₆[2], r₂₆[2]] - low 12 bits only
|
||||||
|
VERIMG $-14&63, T_4, MOD26, H_3 // [h₂₆[1], r₂₆[1]]
|
||||||
|
VESRLG $40, T_4, H_4 // [h₂₆[4], r₂₆[4]] - low 24 bits only
|
||||||
|
VERIMG $+12&63, T_4, T_0, H_2 // [h₂₆[2], r₂₆[2]] - complete
|
||||||
|
VO T_1, H_4, H_4 // [h₂₆[4], r₂₆[4]] - complete
|
||||||
|
|
||||||
|
// replicate r across all 4 vector elements
|
||||||
|
VREPF $3, H_0, R_0 // [r₂₆[0], r₂₆[0], r₂₆[0], r₂₆[0]]
|
||||||
|
VREPF $3, H_1, R_1 // [r₂₆[1], r₂₆[1], r₂₆[1], r₂₆[1]]
|
||||||
|
VREPF $3, H_2, R_2 // [r₂₆[2], r₂₆[2], r₂₆[2], r₂₆[2]]
|
||||||
|
VREPF $3, H_3, R_3 // [r₂₆[3], r₂₆[3], r₂₆[3], r₂₆[3]]
|
||||||
|
VREPF $3, H_4, R_4 // [r₂₆[4], r₂₆[4], r₂₆[4], r₂₆[4]]
|
||||||
|
|
||||||
|
// zero out lane 1 of h
|
||||||
|
VLEIG $1, $0, H_0 // [h₂₆[0], 0]
|
||||||
|
VLEIG $1, $0, H_1 // [h₂₆[1], 0]
|
||||||
|
VLEIG $1, $0, H_2 // [h₂₆[2], 0]
|
||||||
|
VLEIG $1, $0, H_3 // [h₂₆[3], 0]
|
||||||
|
VLEIG $1, $0, H_4 // [h₂₆[4], 0]
|
||||||
|
|
||||||
|
// calculate 5r (ignore least significant limb)
|
||||||
|
VREPIF $5, T_0
|
||||||
|
VMLF T_0, R_1, R5_1 // [5r₂₆[1], 5r₂₆[1], 5r₂₆[1], 5r₂₆[1]]
|
||||||
|
VMLF T_0, R_2, R5_2 // [5r₂₆[2], 5r₂₆[2], 5r₂₆[2], 5r₂₆[2]]
|
||||||
|
VMLF T_0, R_3, R5_3 // [5r₂₆[3], 5r₂₆[3], 5r₂₆[3], 5r₂₆[3]]
|
||||||
|
VMLF T_0, R_4, R5_4 // [5r₂₆[4], 5r₂₆[4], 5r₂₆[4], 5r₂₆[4]]
|
||||||
|
|
||||||
|
// skip r² calculation if we are only calculating one block
|
||||||
|
CMPBLE R3, $16, skip
|
||||||
|
|
||||||
|
// calculate r²
|
||||||
|
MULTIPLY(R_0, R_1, R_2, R_3, R_4, R_0, R_1, R_2, R_3, R_4, R5_1, R5_2, R5_3, R5_4, M_0, M_1, M_2, M_3, M_4)
|
||||||
|
REDUCE(M_0, M_1, M_2, M_3, M_4)
|
||||||
|
VGBM $0x0f0f, T_0
|
||||||
|
VERIMG $0, M_0, T_0, R_0 // [r₂₆[0], r²₂₆[0], r₂₆[0], r²₂₆[0]]
|
||||||
|
VERIMG $0, M_1, T_0, R_1 // [r₂₆[1], r²₂₆[1], r₂₆[1], r²₂₆[1]]
|
||||||
|
VERIMG $0, M_2, T_0, R_2 // [r₂₆[2], r²₂₆[2], r₂₆[2], r²₂₆[2]]
|
||||||
|
VERIMG $0, M_3, T_0, R_3 // [r₂₆[3], r²₂₆[3], r₂₆[3], r²₂₆[3]]
|
||||||
|
VERIMG $0, M_4, T_0, R_4 // [r₂₆[4], r²₂₆[4], r₂₆[4], r²₂₆[4]]
|
||||||
|
|
||||||
|
// calculate 5r² (ignore least significant limb)
|
||||||
|
VREPIF $5, T_0
|
||||||
|
VMLF T_0, R_1, R5_1 // [5r₂₆[1], 5r²₂₆[1], 5r₂₆[1], 5r²₂₆[1]]
|
||||||
|
VMLF T_0, R_2, R5_2 // [5r₂₆[2], 5r²₂₆[2], 5r₂₆[2], 5r²₂₆[2]]
|
||||||
|
VMLF T_0, R_3, R5_3 // [5r₂₆[3], 5r²₂₆[3], 5r₂₆[3], 5r²₂₆[3]]
|
||||||
|
VMLF T_0, R_4, R5_4 // [5r₂₆[4], 5r²₂₆[4], 5r₂₆[4], 5r²₂₆[4]]
|
||||||
|
|
||||||
|
loop:
|
||||||
|
CMPBLE R3, $32, b2 // 2 or fewer blocks remaining, need to change key coefficients
|
||||||
|
|
||||||
|
// load next 2 blocks from message
|
||||||
|
VLM (R2), T_0, T_1
|
||||||
|
|
||||||
|
// update message slice
|
||||||
|
SUB $32, R3
|
||||||
|
MOVD $32(R2), R2
|
||||||
|
|
||||||
|
// unpack message blocks into 26-bit big-endian limbs
|
||||||
|
EXPAND(T_0, T_1, M_0, M_1, M_2, M_3, M_4)
|
||||||
|
|
||||||
|
// add 2¹²⁸ to each message block value
|
||||||
|
VLEIB $4, $1, M_4
|
||||||
|
VLEIB $12, $1, M_4
|
||||||
|
|
||||||
|
multiply:
|
||||||
|
// accumulate the incoming message
|
||||||
|
VAG H_0, M_0, M_0
|
||||||
|
VAG H_3, M_3, M_3
|
||||||
|
VAG H_1, M_1, M_1
|
||||||
|
VAG H_4, M_4, M_4
|
||||||
|
VAG H_2, M_2, M_2
|
||||||
|
|
||||||
|
// multiply the accumulator by the key coefficient
|
||||||
|
MULTIPLY(M_0, M_1, M_2, M_3, M_4, R_0, R_1, R_2, R_3, R_4, R5_1, R5_2, R5_3, R5_4, H_0, H_1, H_2, H_3, H_4)
|
||||||
|
|
||||||
|
// carry and partially reduce the partial products
|
||||||
|
REDUCE(H_0, H_1, H_2, H_3, H_4)
|
||||||
|
|
||||||
|
CMPBNE R3, $0, loop
|
||||||
|
|
||||||
|
finish:
|
||||||
|
// sum lane 0 and lane 1 and put the result in lane 1
|
||||||
|
VZERO T_0
|
||||||
|
VSUMQG H_0, T_0, H_0
|
||||||
|
VSUMQG H_3, T_0, H_3
|
||||||
|
VSUMQG H_1, T_0, H_1
|
||||||
|
VSUMQG H_4, T_0, H_4
|
||||||
|
VSUMQG H_2, T_0, H_2
|
||||||
|
|
||||||
|
// reduce again after summation
|
||||||
|
// TODO(mundaym): there might be a more efficient way to do this
|
||||||
|
// now that we only have 1 active lane. For example, we could
|
||||||
|
// simultaneously pack the values as we reduce them.
|
||||||
|
REDUCE(H_0, H_1, H_2, H_3, H_4)
|
||||||
|
|
||||||
|
// carry h[1] through to h[4] so that only h[4] can exceed 2²⁶ - 1
|
||||||
|
// TODO(mundaym): in testing this final carry was unnecessary.
|
||||||
|
// Needs a proof before it can be removed though.
|
||||||
|
VESRLG $26, H_1, T_1
|
||||||
|
VN MOD26, H_1, H_1
|
||||||
|
VAQ T_1, H_2, H_2
|
||||||
|
VESRLG $26, H_2, T_2
|
||||||
|
VN MOD26, H_2, H_2
|
||||||
|
VAQ T_2, H_3, H_3
|
||||||
|
VESRLG $26, H_3, T_3
|
||||||
|
VN MOD26, H_3, H_3
|
||||||
|
VAQ T_3, H_4, H_4
|
||||||
|
|
||||||
|
// h is now < 2(2¹³⁰ - 5)
|
||||||
|
// Pack each lane in h₂₆[0:4] into h₁₂₈[0:1].
|
||||||
|
VESLG $26, H_1, H_1
|
||||||
|
VESLG $26, H_3, H_3
|
||||||
|
VO H_0, H_1, H_0
|
||||||
|
VO H_2, H_3, H_2
|
||||||
|
VESLG $4, H_2, H_2
|
||||||
|
VLEIB $7, $48, H_1
|
||||||
|
VSLB H_1, H_2, H_2
|
||||||
|
VO H_0, H_2, H_0
|
||||||
|
VLEIB $7, $104, H_1
|
||||||
|
VSLB H_1, H_4, H_3
|
||||||
|
VO H_3, H_0, H_0
|
||||||
|
VLEIB $7, $24, H_1
|
||||||
|
VSRLB H_1, H_4, H_1
|
||||||
|
|
||||||
|
// update state
|
||||||
|
VSTEG $1, H_0, 0(R1)
|
||||||
|
VSTEG $0, H_0, 8(R1)
|
||||||
|
VSTEG $1, H_1, 16(R1)
|
||||||
|
RET
|
||||||
|
|
||||||
|
b2: // 2 or fewer blocks remaining
|
||||||
|
CMPBLE R3, $16, b1
|
||||||
|
|
||||||
|
// Load the 2 remaining blocks (17-32 bytes remaining).
|
||||||
|
MOVD $-17(R3), R0 // index of final byte to load modulo 16
|
||||||
|
VL (R2), T_0 // load full 16 byte block
|
||||||
|
VLL R0, 16(R2), T_1 // load final (possibly partial) block and pad with zeros to 16 bytes
|
||||||
|
|
||||||
|
// The Poly1305 algorithm requires that a 1 bit be appended to
|
||||||
|
// each message block. If the final block is less than 16 bytes
|
||||||
|
// long then it is easiest to insert the 1 before the message
|
||||||
|
// block is split into 26-bit limbs. If, on the other hand, the
|
||||||
|
// final message block is 16 bytes long then we append the 1 bit
|
||||||
|
// after expansion as normal.
|
||||||
|
MOVBZ $1, R0
|
||||||
|
MOVD $-16(R3), R3 // index of byte in last block to insert 1 at (could be 16)
|
||||||
|
CMPBEQ R3, $16, 2(PC) // skip the insertion if the final block is 16 bytes long
|
||||||
|
VLVGB R3, R0, T_1 // insert 1 into the byte at index R3
|
||||||
|
|
||||||
|
// Split both blocks into 26-bit limbs in the appropriate lanes.
|
||||||
|
EXPAND(T_0, T_1, M_0, M_1, M_2, M_3, M_4)
|
||||||
|
|
||||||
|
// Append a 1 byte to the end of the second to last block.
|
||||||
|
VLEIB $4, $1, M_4
|
||||||
|
|
||||||
|
// Append a 1 byte to the end of the last block only if it is a
|
||||||
|
// full 16 byte block.
|
||||||
|
CMPBNE R3, $16, 2(PC)
|
||||||
|
VLEIB $12, $1, M_4
|
||||||
|
|
||||||
|
// Finally, set up the coefficients for the final multiplication.
|
||||||
|
// We have previously saved r and 5r in the 32-bit even indexes
|
||||||
|
// of the R_[0-4] and R5_[1-4] coefficient registers.
|
||||||
|
//
|
||||||
|
// We want lane 0 to be multiplied by r² so that can be kept the
|
||||||
|
// same. We want lane 1 to be multiplied by r so we need to move
|
||||||
|
// the saved r value into the 32-bit odd index in lane 1 by
|
||||||
|
// rotating the 64-bit lane by 32.
|
||||||
|
VGBM $0x00ff, T_0 // [0, 0xffffffffffffffff] - mask lane 1 only
|
||||||
|
VERIMG $32, R_0, T_0, R_0 // [_, r²₂₆[0], _, r₂₆[0]]
|
||||||
|
VERIMG $32, R_1, T_0, R_1 // [_, r²₂₆[1], _, r₂₆[1]]
|
||||||
|
VERIMG $32, R_2, T_0, R_2 // [_, r²₂₆[2], _, r₂₆[2]]
|
||||||
|
VERIMG $32, R_3, T_0, R_3 // [_, r²₂₆[3], _, r₂₆[3]]
|
||||||
|
VERIMG $32, R_4, T_0, R_4 // [_, r²₂₆[4], _, r₂₆[4]]
|
||||||
|
VERIMG $32, R5_1, T_0, R5_1 // [_, 5r²₂₆[1], _, 5r₂₆[1]]
|
||||||
|
VERIMG $32, R5_2, T_0, R5_2 // [_, 5r²₂₆[2], _, 5r₂₆[2]]
|
||||||
|
VERIMG $32, R5_3, T_0, R5_3 // [_, 5r²₂₆[3], _, 5r₂₆[3]]
|
||||||
|
VERIMG $32, R5_4, T_0, R5_4 // [_, 5r²₂₆[4], _, 5r₂₆[4]]
|
||||||
|
|
||||||
|
MOVD $0, R3
|
||||||
|
BR multiply
|
||||||
|
|
||||||
|
skip:
|
||||||
|
CMPBEQ R3, $0, finish
|
||||||
|
|
||||||
|
b1: // 1 block remaining
|
||||||
|
|
||||||
|
// Load the final block (1-16 bytes). This will be placed into
|
||||||
|
// lane 0.
|
||||||
|
MOVD $-1(R3), R0
|
||||||
|
VLL R0, (R2), T_0 // pad to 16 bytes with zeros
|
||||||
|
|
||||||
|
// The Poly1305 algorithm requires that a 1 bit be appended to
|
||||||
|
// each message block. If the final block is less than 16 bytes
|
||||||
|
// long then it is easiest to insert the 1 before the message
|
||||||
|
// block is split into 26-bit limbs. If, on the other hand, the
|
||||||
|
// final message block is 16 bytes long then we append the 1 bit
|
||||||
|
// after expansion as normal.
|
||||||
|
MOVBZ $1, R0
|
||||||
|
CMPBEQ R3, $16, 2(PC)
|
||||||
|
VLVGB R3, R0, T_0
|
||||||
|
|
||||||
|
// Set the message block in lane 1 to the value 0 so that it
|
||||||
|
// can be accumulated without affecting the final result.
|
||||||
|
VZERO T_1
|
||||||
|
|
||||||
|
// Split the final message block into 26-bit limbs in lane 0.
|
||||||
|
// Lane 1 will be contain 0.
|
||||||
|
EXPAND(T_0, T_1, M_0, M_1, M_2, M_3, M_4)
|
||||||
|
|
||||||
|
// Append a 1 byte to the end of the last block only if it is a
|
||||||
|
// full 16 byte block.
|
||||||
|
CMPBNE R3, $16, 2(PC)
|
||||||
|
VLEIB $4, $1, M_4
|
||||||
|
|
||||||
|
// We have previously saved r and 5r in the 32-bit even indexes
|
||||||
|
// of the R_[0-4] and R5_[1-4] coefficient registers.
|
||||||
|
//
|
||||||
|
// We want lane 0 to be multiplied by r so we need to move the
|
||||||
|
// saved r value into the 32-bit odd index in lane 0. We want
|
||||||
|
// lane 1 to be set to the value 1. This makes multiplication
|
||||||
|
// a no-op. We do this by setting lane 1 in every register to 0
|
||||||
|
// and then just setting the 32-bit index 3 in R_0 to 1.
|
||||||
|
VZERO T_0
|
||||||
|
MOVD $0, R0
|
||||||
|
MOVD $0x10111213, R12
|
||||||
|
VLVGP R12, R0, T_1 // [_, 0x10111213, _, 0x00000000]
|
||||||
|
VPERM T_0, R_0, T_1, R_0 // [_, r₂₆[0], _, 0]
|
||||||
|
VPERM T_0, R_1, T_1, R_1 // [_, r₂₆[1], _, 0]
|
||||||
|
VPERM T_0, R_2, T_1, R_2 // [_, r₂₆[2], _, 0]
|
||||||
|
VPERM T_0, R_3, T_1, R_3 // [_, r₂₆[3], _, 0]
|
||||||
|
VPERM T_0, R_4, T_1, R_4 // [_, r₂₆[4], _, 0]
|
||||||
|
VPERM T_0, R5_1, T_1, R5_1 // [_, 5r₂₆[1], _, 0]
|
||||||
|
VPERM T_0, R5_2, T_1, R5_2 // [_, 5r₂₆[2], _, 0]
|
||||||
|
VPERM T_0, R5_3, T_1, R5_3 // [_, 5r₂₆[3], _, 0]
|
||||||
|
VPERM T_0, R5_4, T_1, R5_4 // [_, 5r₂₆[4], _, 0]
|
||||||
|
|
||||||
|
// Set the value of lane 1 to be 1.
|
||||||
|
VLEIF $3, $1, R_0 // [_, r₂₆[0], _, 1]
|
||||||
|
|
||||||
|
MOVD $0, R3
|
||||||
|
BR multiply
|
33
vendor/golang.org/x/crypto/internal/subtle/aliasing.go
generated
vendored
Normal file
33
vendor/golang.org/x/crypto/internal/subtle/aliasing.go
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build !purego
|
||||||
|
// +build !purego
|
||||||
|
|
||||||
|
// Package subtle implements functions that are often useful in cryptographic
|
||||||
|
// code but require careful thought to use correctly.
|
||||||
|
package subtle // import "golang.org/x/crypto/internal/subtle"
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// AnyOverlap reports whether x and y share memory at any (not necessarily
|
||||||
|
// corresponding) index. The memory beyond the slice length is ignored.
|
||||||
|
func AnyOverlap(x, y []byte) bool {
|
||||||
|
return len(x) > 0 && len(y) > 0 &&
|
||||||
|
uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) &&
|
||||||
|
uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InexactOverlap reports whether x and y share memory at any non-corresponding
|
||||||
|
// index. The memory beyond the slice length is ignored. Note that x and y can
|
||||||
|
// have different lengths and still not have any inexact overlap.
|
||||||
|
//
|
||||||
|
// InexactOverlap can be used to implement the requirements of the crypto/cipher
|
||||||
|
// AEAD, Block, BlockMode and Stream interfaces.
|
||||||
|
func InexactOverlap(x, y []byte) bool {
|
||||||
|
if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return AnyOverlap(x, y)
|
||||||
|
}
|
36
vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go
generated
vendored
Normal file
36
vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build purego
|
||||||
|
// +build purego
|
||||||
|
|
||||||
|
// Package subtle implements functions that are often useful in cryptographic
|
||||||
|
// code but require careful thought to use correctly.
|
||||||
|
package subtle // import "golang.org/x/crypto/internal/subtle"
|
||||||
|
|
||||||
|
// This is the Google App Engine standard variant based on reflect
|
||||||
|
// because the unsafe package and cgo are disallowed.
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
|
// AnyOverlap reports whether x and y share memory at any (not necessarily
|
||||||
|
// corresponding) index. The memory beyond the slice length is ignored.
|
||||||
|
func AnyOverlap(x, y []byte) bool {
|
||||||
|
return len(x) > 0 && len(y) > 0 &&
|
||||||
|
reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() &&
|
||||||
|
reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// InexactOverlap reports whether x and y share memory at any non-corresponding
|
||||||
|
// index. The memory beyond the slice length is ignored. Note that x and y can
|
||||||
|
// have different lengths and still not have any inexact overlap.
|
||||||
|
//
|
||||||
|
// InexactOverlap can be used to implement the requirements of the crypto/cipher
|
||||||
|
// AEAD, Block, BlockMode and Stream interfaces.
|
||||||
|
func InexactOverlap(x, y []byte) bool {
|
||||||
|
if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return AnyOverlap(x, y)
|
||||||
|
}
|
182
vendor/golang.org/x/crypto/nacl/box/box.go
generated
vendored
Normal file
182
vendor/golang.org/x/crypto/nacl/box/box.go
generated
vendored
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package box authenticates and encrypts small messages using public-key cryptography.
|
||||||
|
|
||||||
|
Box uses Curve25519, XSalsa20 and Poly1305 to encrypt and authenticate
|
||||||
|
messages. The length of messages is not hidden.
|
||||||
|
|
||||||
|
It is the caller's responsibility to ensure the uniqueness of nonces—for
|
||||||
|
example, by using nonce 1 for the first message, nonce 2 for the second
|
||||||
|
message, etc. Nonces are long enough that randomly generated nonces have
|
||||||
|
negligible risk of collision.
|
||||||
|
|
||||||
|
Messages should be small because:
|
||||||
|
|
||||||
|
1. The whole message needs to be held in memory to be processed.
|
||||||
|
|
||||||
|
2. Using large messages pressures implementations on small machines to decrypt
|
||||||
|
and process plaintext before authenticating it. This is very dangerous, and
|
||||||
|
this API does not allow it, but a protocol that uses excessive message sizes
|
||||||
|
might present some implementations with no other choice.
|
||||||
|
|
||||||
|
3. Fixed overheads will be sufficiently amortised by messages as small as 8KB.
|
||||||
|
|
||||||
|
4. Performance may be improved by working with messages that fit into data caches.
|
||||||
|
|
||||||
|
Thus large amounts of data should be chunked so that each message is small.
|
||||||
|
(Each message still needs a unique nonce.) If in doubt, 16KB is a reasonable
|
||||||
|
chunk size.
|
||||||
|
|
||||||
|
This package is interoperable with NaCl: https://nacl.cr.yp.to/box.html.
|
||||||
|
Anonymous sealing/opening is an extension of NaCl defined by and interoperable
|
||||||
|
with libsodium:
|
||||||
|
https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes.
|
||||||
|
*/
|
||||||
|
package box // import "golang.org/x/crypto/nacl/box"
|
||||||
|
|
||||||
|
import (
|
||||||
|
cryptorand "crypto/rand"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/blake2b"
|
||||||
|
"golang.org/x/crypto/curve25519"
|
||||||
|
"golang.org/x/crypto/nacl/secretbox"
|
||||||
|
"golang.org/x/crypto/salsa20/salsa"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Overhead is the number of bytes of overhead when boxing a message.
|
||||||
|
Overhead = secretbox.Overhead
|
||||||
|
|
||||||
|
// AnonymousOverhead is the number of bytes of overhead when using anonymous
|
||||||
|
// sealed boxes.
|
||||||
|
AnonymousOverhead = Overhead + 32
|
||||||
|
)
|
||||||
|
|
||||||
|
// GenerateKey generates a new public/private key pair suitable for use with
|
||||||
|
// Seal and Open.
|
||||||
|
func GenerateKey(rand io.Reader) (publicKey, privateKey *[32]byte, err error) {
|
||||||
|
publicKey = new([32]byte)
|
||||||
|
privateKey = new([32]byte)
|
||||||
|
_, err = io.ReadFull(rand, privateKey[:])
|
||||||
|
if err != nil {
|
||||||
|
publicKey = nil
|
||||||
|
privateKey = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
curve25519.ScalarBaseMult(publicKey, privateKey)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var zeros [16]byte
|
||||||
|
|
||||||
|
// Precompute calculates the shared key between peersPublicKey and privateKey
|
||||||
|
// and writes it to sharedKey. The shared key can be used with
|
||||||
|
// OpenAfterPrecomputation and SealAfterPrecomputation to speed up processing
|
||||||
|
// when using the same pair of keys repeatedly.
|
||||||
|
func Precompute(sharedKey, peersPublicKey, privateKey *[32]byte) {
|
||||||
|
curve25519.ScalarMult(sharedKey, privateKey, peersPublicKey)
|
||||||
|
salsa.HSalsa20(sharedKey, &zeros, sharedKey, &salsa.Sigma)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seal appends an encrypted and authenticated copy of message to out, which
|
||||||
|
// will be Overhead bytes longer than the original and must not overlap it. The
|
||||||
|
// nonce must be unique for each distinct message for a given pair of keys.
|
||||||
|
func Seal(out, message []byte, nonce *[24]byte, peersPublicKey, privateKey *[32]byte) []byte {
|
||||||
|
var sharedKey [32]byte
|
||||||
|
Precompute(&sharedKey, peersPublicKey, privateKey)
|
||||||
|
return secretbox.Seal(out, message, nonce, &sharedKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SealAfterPrecomputation performs the same actions as Seal, but takes a
|
||||||
|
// shared key as generated by Precompute.
|
||||||
|
func SealAfterPrecomputation(out, message []byte, nonce *[24]byte, sharedKey *[32]byte) []byte {
|
||||||
|
return secretbox.Seal(out, message, nonce, sharedKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open authenticates and decrypts a box produced by Seal and appends the
|
||||||
|
// message to out, which must not overlap box. The output will be Overhead
|
||||||
|
// bytes smaller than box.
|
||||||
|
func Open(out, box []byte, nonce *[24]byte, peersPublicKey, privateKey *[32]byte) ([]byte, bool) {
|
||||||
|
var sharedKey [32]byte
|
||||||
|
Precompute(&sharedKey, peersPublicKey, privateKey)
|
||||||
|
return secretbox.Open(out, box, nonce, &sharedKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenAfterPrecomputation performs the same actions as Open, but takes a
|
||||||
|
// shared key as generated by Precompute.
|
||||||
|
func OpenAfterPrecomputation(out, box []byte, nonce *[24]byte, sharedKey *[32]byte) ([]byte, bool) {
|
||||||
|
return secretbox.Open(out, box, nonce, sharedKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SealAnonymous appends an encrypted and authenticated copy of message to out,
|
||||||
|
// which will be AnonymousOverhead bytes longer than the original and must not
|
||||||
|
// overlap it. This differs from Seal in that the sender is not required to
|
||||||
|
// provide a private key.
|
||||||
|
func SealAnonymous(out, message []byte, recipient *[32]byte, rand io.Reader) ([]byte, error) {
|
||||||
|
if rand == nil {
|
||||||
|
rand = cryptorand.Reader
|
||||||
|
}
|
||||||
|
ephemeralPub, ephemeralPriv, err := GenerateKey(rand)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var nonce [24]byte
|
||||||
|
if err := sealNonce(ephemeralPub, recipient, &nonce); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if total := len(out) + AnonymousOverhead + len(message); cap(out) < total {
|
||||||
|
original := out
|
||||||
|
out = make([]byte, 0, total)
|
||||||
|
out = append(out, original...)
|
||||||
|
}
|
||||||
|
out = append(out, ephemeralPub[:]...)
|
||||||
|
|
||||||
|
return Seal(out, message, &nonce, recipient, ephemeralPriv), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenAnonymous authenticates and decrypts a box produced by SealAnonymous and
|
||||||
|
// appends the message to out, which must not overlap box. The output will be
|
||||||
|
// AnonymousOverhead bytes smaller than box.
|
||||||
|
func OpenAnonymous(out, box []byte, publicKey, privateKey *[32]byte) (message []byte, ok bool) {
|
||||||
|
if len(box) < AnonymousOverhead {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
var ephemeralPub [32]byte
|
||||||
|
copy(ephemeralPub[:], box[:32])
|
||||||
|
|
||||||
|
var nonce [24]byte
|
||||||
|
if err := sealNonce(&ephemeralPub, publicKey, &nonce); err != nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return Open(out, box[32:], &nonce, &ephemeralPub, privateKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sealNonce generates a 24 byte nonce that is a blake2b digest of the
|
||||||
|
// ephemeral public key and the receiver's public key.
|
||||||
|
func sealNonce(ephemeralPub, peersPublicKey *[32]byte, nonce *[24]byte) error {
|
||||||
|
h, err := blake2b.New(24, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = h.Write(ephemeralPub[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = h.Write(peersPublicKey[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Sum(nonce[:0])
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
173
vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go
generated
vendored
Normal file
173
vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go
generated
vendored
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package secretbox encrypts and authenticates small messages.
|
||||||
|
|
||||||
|
Secretbox uses XSalsa20 and Poly1305 to encrypt and authenticate messages with
|
||||||
|
secret-key cryptography. The length of messages is not hidden.
|
||||||
|
|
||||||
|
It is the caller's responsibility to ensure the uniqueness of nonces—for
|
||||||
|
example, by using nonce 1 for the first message, nonce 2 for the second
|
||||||
|
message, etc. Nonces are long enough that randomly generated nonces have
|
||||||
|
negligible risk of collision.
|
||||||
|
|
||||||
|
Messages should be small because:
|
||||||
|
|
||||||
|
1. The whole message needs to be held in memory to be processed.
|
||||||
|
|
||||||
|
2. Using large messages pressures implementations on small machines to decrypt
|
||||||
|
and process plaintext before authenticating it. This is very dangerous, and
|
||||||
|
this API does not allow it, but a protocol that uses excessive message sizes
|
||||||
|
might present some implementations with no other choice.
|
||||||
|
|
||||||
|
3. Fixed overheads will be sufficiently amortised by messages as small as 8KB.
|
||||||
|
|
||||||
|
4. Performance may be improved by working with messages that fit into data caches.
|
||||||
|
|
||||||
|
Thus large amounts of data should be chunked so that each message is small.
|
||||||
|
(Each message still needs a unique nonce.) If in doubt, 16KB is a reasonable
|
||||||
|
chunk size.
|
||||||
|
|
||||||
|
This package is interoperable with NaCl: https://nacl.cr.yp.to/secretbox.html.
|
||||||
|
*/
|
||||||
|
package secretbox // import "golang.org/x/crypto/nacl/secretbox"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/crypto/internal/poly1305"
|
||||||
|
"golang.org/x/crypto/internal/subtle"
|
||||||
|
"golang.org/x/crypto/salsa20/salsa"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Overhead is the number of bytes of overhead when boxing a message.
|
||||||
|
const Overhead = poly1305.TagSize
|
||||||
|
|
||||||
|
// setup produces a sub-key and Salsa20 counter given a nonce and key.
|
||||||
|
func setup(subKey *[32]byte, counter *[16]byte, nonce *[24]byte, key *[32]byte) {
|
||||||
|
// We use XSalsa20 for encryption so first we need to generate a
|
||||||
|
// key and nonce with HSalsa20.
|
||||||
|
var hNonce [16]byte
|
||||||
|
copy(hNonce[:], nonce[:])
|
||||||
|
salsa.HSalsa20(subKey, &hNonce, key, &salsa.Sigma)
|
||||||
|
|
||||||
|
// The final 8 bytes of the original nonce form the new nonce.
|
||||||
|
copy(counter[:], nonce[16:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// sliceForAppend takes a slice and a requested number of bytes. It returns a
|
||||||
|
// slice with the contents of the given slice followed by that many bytes and a
|
||||||
|
// second slice that aliases into it and contains only the extra bytes. If the
|
||||||
|
// original slice has sufficient capacity then no allocation is performed.
|
||||||
|
func sliceForAppend(in []byte, n int) (head, tail []byte) {
|
||||||
|
if total := len(in) + n; cap(in) >= total {
|
||||||
|
head = in[:total]
|
||||||
|
} else {
|
||||||
|
head = make([]byte, total)
|
||||||
|
copy(head, in)
|
||||||
|
}
|
||||||
|
tail = head[len(in):]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seal appends an encrypted and authenticated copy of message to out, which
|
||||||
|
// must not overlap message. The key and nonce pair must be unique for each
|
||||||
|
// distinct message and the output will be Overhead bytes longer than message.
|
||||||
|
func Seal(out, message []byte, nonce *[24]byte, key *[32]byte) []byte {
|
||||||
|
var subKey [32]byte
|
||||||
|
var counter [16]byte
|
||||||
|
setup(&subKey, &counter, nonce, key)
|
||||||
|
|
||||||
|
// The Poly1305 key is generated by encrypting 32 bytes of zeros. Since
|
||||||
|
// Salsa20 works with 64-byte blocks, we also generate 32 bytes of
|
||||||
|
// keystream as a side effect.
|
||||||
|
var firstBlock [64]byte
|
||||||
|
salsa.XORKeyStream(firstBlock[:], firstBlock[:], &counter, &subKey)
|
||||||
|
|
||||||
|
var poly1305Key [32]byte
|
||||||
|
copy(poly1305Key[:], firstBlock[:])
|
||||||
|
|
||||||
|
ret, out := sliceForAppend(out, len(message)+poly1305.TagSize)
|
||||||
|
if subtle.AnyOverlap(out, message) {
|
||||||
|
panic("nacl: invalid buffer overlap")
|
||||||
|
}
|
||||||
|
|
||||||
|
// We XOR up to 32 bytes of message with the keystream generated from
|
||||||
|
// the first block.
|
||||||
|
firstMessageBlock := message
|
||||||
|
if len(firstMessageBlock) > 32 {
|
||||||
|
firstMessageBlock = firstMessageBlock[:32]
|
||||||
|
}
|
||||||
|
|
||||||
|
tagOut := out
|
||||||
|
out = out[poly1305.TagSize:]
|
||||||
|
for i, x := range firstMessageBlock {
|
||||||
|
out[i] = firstBlock[32+i] ^ x
|
||||||
|
}
|
||||||
|
message = message[len(firstMessageBlock):]
|
||||||
|
ciphertext := out
|
||||||
|
out = out[len(firstMessageBlock):]
|
||||||
|
|
||||||
|
// Now encrypt the rest.
|
||||||
|
counter[8] = 1
|
||||||
|
salsa.XORKeyStream(out, message, &counter, &subKey)
|
||||||
|
|
||||||
|
var tag [poly1305.TagSize]byte
|
||||||
|
poly1305.Sum(&tag, ciphertext, &poly1305Key)
|
||||||
|
copy(tagOut, tag[:])
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open authenticates and decrypts a box produced by Seal and appends the
|
||||||
|
// message to out, which must not overlap box. The output will be Overhead
|
||||||
|
// bytes smaller than box.
|
||||||
|
func Open(out, box []byte, nonce *[24]byte, key *[32]byte) ([]byte, bool) {
|
||||||
|
if len(box) < Overhead {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
var subKey [32]byte
|
||||||
|
var counter [16]byte
|
||||||
|
setup(&subKey, &counter, nonce, key)
|
||||||
|
|
||||||
|
// The Poly1305 key is generated by encrypting 32 bytes of zeros. Since
|
||||||
|
// Salsa20 works with 64-byte blocks, we also generate 32 bytes of
|
||||||
|
// keystream as a side effect.
|
||||||
|
var firstBlock [64]byte
|
||||||
|
salsa.XORKeyStream(firstBlock[:], firstBlock[:], &counter, &subKey)
|
||||||
|
|
||||||
|
var poly1305Key [32]byte
|
||||||
|
copy(poly1305Key[:], firstBlock[:])
|
||||||
|
var tag [poly1305.TagSize]byte
|
||||||
|
copy(tag[:], box)
|
||||||
|
|
||||||
|
if !poly1305.Verify(&tag, box[poly1305.TagSize:], &poly1305Key) {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
ret, out := sliceForAppend(out, len(box)-Overhead)
|
||||||
|
if subtle.AnyOverlap(out, box) {
|
||||||
|
panic("nacl: invalid buffer overlap")
|
||||||
|
}
|
||||||
|
|
||||||
|
// We XOR up to 32 bytes of box with the keystream generated from
|
||||||
|
// the first block.
|
||||||
|
box = box[Overhead:]
|
||||||
|
firstMessageBlock := box
|
||||||
|
if len(firstMessageBlock) > 32 {
|
||||||
|
firstMessageBlock = firstMessageBlock[:32]
|
||||||
|
}
|
||||||
|
for i, x := range firstMessageBlock {
|
||||||
|
out[i] = firstBlock[32+i] ^ x
|
||||||
|
}
|
||||||
|
|
||||||
|
box = box[len(firstMessageBlock):]
|
||||||
|
out = out[len(firstMessageBlock):]
|
||||||
|
|
||||||
|
// Now decrypt the rest.
|
||||||
|
counter[8] = 1
|
||||||
|
salsa.XORKeyStream(out, box, &counter, &subKey)
|
||||||
|
|
||||||
|
return ret, true
|
||||||
|
}
|
144
vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go
generated
vendored
Normal file
144
vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go
generated
vendored
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// Package salsa provides low-level access to functions in the Salsa family.
|
||||||
|
package salsa // import "golang.org/x/crypto/salsa20/salsa"
|
||||||
|
|
||||||
|
// Sigma is the Salsa20 constant for 256-bit keys.
|
||||||
|
var Sigma = [16]byte{'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k'}
|
||||||
|
|
||||||
|
// HSalsa20 applies the HSalsa20 core function to a 16-byte input in, 32-byte
|
||||||
|
// key k, and 16-byte constant c, and puts the result into the 32-byte array
|
||||||
|
// out.
|
||||||
|
func HSalsa20(out *[32]byte, in *[16]byte, k *[32]byte, c *[16]byte) {
|
||||||
|
x0 := uint32(c[0]) | uint32(c[1])<<8 | uint32(c[2])<<16 | uint32(c[3])<<24
|
||||||
|
x1 := uint32(k[0]) | uint32(k[1])<<8 | uint32(k[2])<<16 | uint32(k[3])<<24
|
||||||
|
x2 := uint32(k[4]) | uint32(k[5])<<8 | uint32(k[6])<<16 | uint32(k[7])<<24
|
||||||
|
x3 := uint32(k[8]) | uint32(k[9])<<8 | uint32(k[10])<<16 | uint32(k[11])<<24
|
||||||
|
x4 := uint32(k[12]) | uint32(k[13])<<8 | uint32(k[14])<<16 | uint32(k[15])<<24
|
||||||
|
x5 := uint32(c[4]) | uint32(c[5])<<8 | uint32(c[6])<<16 | uint32(c[7])<<24
|
||||||
|
x6 := uint32(in[0]) | uint32(in[1])<<8 | uint32(in[2])<<16 | uint32(in[3])<<24
|
||||||
|
x7 := uint32(in[4]) | uint32(in[5])<<8 | uint32(in[6])<<16 | uint32(in[7])<<24
|
||||||
|
x8 := uint32(in[8]) | uint32(in[9])<<8 | uint32(in[10])<<16 | uint32(in[11])<<24
|
||||||
|
x9 := uint32(in[12]) | uint32(in[13])<<8 | uint32(in[14])<<16 | uint32(in[15])<<24
|
||||||
|
x10 := uint32(c[8]) | uint32(c[9])<<8 | uint32(c[10])<<16 | uint32(c[11])<<24
|
||||||
|
x11 := uint32(k[16]) | uint32(k[17])<<8 | uint32(k[18])<<16 | uint32(k[19])<<24
|
||||||
|
x12 := uint32(k[20]) | uint32(k[21])<<8 | uint32(k[22])<<16 | uint32(k[23])<<24
|
||||||
|
x13 := uint32(k[24]) | uint32(k[25])<<8 | uint32(k[26])<<16 | uint32(k[27])<<24
|
||||||
|
x14 := uint32(k[28]) | uint32(k[29])<<8 | uint32(k[30])<<16 | uint32(k[31])<<24
|
||||||
|
x15 := uint32(c[12]) | uint32(c[13])<<8 | uint32(c[14])<<16 | uint32(c[15])<<24
|
||||||
|
|
||||||
|
for i := 0; i < 20; i += 2 {
|
||||||
|
u := x0 + x12
|
||||||
|
x4 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x4 + x0
|
||||||
|
x8 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x8 + x4
|
||||||
|
x12 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x12 + x8
|
||||||
|
x0 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x5 + x1
|
||||||
|
x9 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x9 + x5
|
||||||
|
x13 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x13 + x9
|
||||||
|
x1 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x1 + x13
|
||||||
|
x5 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x10 + x6
|
||||||
|
x14 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x14 + x10
|
||||||
|
x2 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x2 + x14
|
||||||
|
x6 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x6 + x2
|
||||||
|
x10 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x15 + x11
|
||||||
|
x3 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x3 + x15
|
||||||
|
x7 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x7 + x3
|
||||||
|
x11 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x11 + x7
|
||||||
|
x15 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x0 + x3
|
||||||
|
x1 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x1 + x0
|
||||||
|
x2 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x2 + x1
|
||||||
|
x3 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x3 + x2
|
||||||
|
x0 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x5 + x4
|
||||||
|
x6 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x6 + x5
|
||||||
|
x7 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x7 + x6
|
||||||
|
x4 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x4 + x7
|
||||||
|
x5 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x10 + x9
|
||||||
|
x11 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x11 + x10
|
||||||
|
x8 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x8 + x11
|
||||||
|
x9 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x9 + x8
|
||||||
|
x10 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x15 + x14
|
||||||
|
x12 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x12 + x15
|
||||||
|
x13 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x13 + x12
|
||||||
|
x14 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x14 + x13
|
||||||
|
x15 ^= u<<18 | u>>(32-18)
|
||||||
|
}
|
||||||
|
out[0] = byte(x0)
|
||||||
|
out[1] = byte(x0 >> 8)
|
||||||
|
out[2] = byte(x0 >> 16)
|
||||||
|
out[3] = byte(x0 >> 24)
|
||||||
|
|
||||||
|
out[4] = byte(x5)
|
||||||
|
out[5] = byte(x5 >> 8)
|
||||||
|
out[6] = byte(x5 >> 16)
|
||||||
|
out[7] = byte(x5 >> 24)
|
||||||
|
|
||||||
|
out[8] = byte(x10)
|
||||||
|
out[9] = byte(x10 >> 8)
|
||||||
|
out[10] = byte(x10 >> 16)
|
||||||
|
out[11] = byte(x10 >> 24)
|
||||||
|
|
||||||
|
out[12] = byte(x15)
|
||||||
|
out[13] = byte(x15 >> 8)
|
||||||
|
out[14] = byte(x15 >> 16)
|
||||||
|
out[15] = byte(x15 >> 24)
|
||||||
|
|
||||||
|
out[16] = byte(x6)
|
||||||
|
out[17] = byte(x6 >> 8)
|
||||||
|
out[18] = byte(x6 >> 16)
|
||||||
|
out[19] = byte(x6 >> 24)
|
||||||
|
|
||||||
|
out[20] = byte(x7)
|
||||||
|
out[21] = byte(x7 >> 8)
|
||||||
|
out[22] = byte(x7 >> 16)
|
||||||
|
out[23] = byte(x7 >> 24)
|
||||||
|
|
||||||
|
out[24] = byte(x8)
|
||||||
|
out[25] = byte(x8 >> 8)
|
||||||
|
out[26] = byte(x8 >> 16)
|
||||||
|
out[27] = byte(x8 >> 24)
|
||||||
|
|
||||||
|
out[28] = byte(x9)
|
||||||
|
out[29] = byte(x9 >> 8)
|
||||||
|
out[30] = byte(x9 >> 16)
|
||||||
|
out[31] = byte(x9 >> 24)
|
||||||
|
}
|
199
vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go
generated
vendored
Normal file
199
vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go
generated
vendored
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
package salsa
|
||||||
|
|
||||||
|
// Core208 applies the Salsa20/8 core function to the 64-byte array in and puts
|
||||||
|
// the result into the 64-byte array out. The input and output may be the same array.
|
||||||
|
func Core208(out *[64]byte, in *[64]byte) {
|
||||||
|
j0 := uint32(in[0]) | uint32(in[1])<<8 | uint32(in[2])<<16 | uint32(in[3])<<24
|
||||||
|
j1 := uint32(in[4]) | uint32(in[5])<<8 | uint32(in[6])<<16 | uint32(in[7])<<24
|
||||||
|
j2 := uint32(in[8]) | uint32(in[9])<<8 | uint32(in[10])<<16 | uint32(in[11])<<24
|
||||||
|
j3 := uint32(in[12]) | uint32(in[13])<<8 | uint32(in[14])<<16 | uint32(in[15])<<24
|
||||||
|
j4 := uint32(in[16]) | uint32(in[17])<<8 | uint32(in[18])<<16 | uint32(in[19])<<24
|
||||||
|
j5 := uint32(in[20]) | uint32(in[21])<<8 | uint32(in[22])<<16 | uint32(in[23])<<24
|
||||||
|
j6 := uint32(in[24]) | uint32(in[25])<<8 | uint32(in[26])<<16 | uint32(in[27])<<24
|
||||||
|
j7 := uint32(in[28]) | uint32(in[29])<<8 | uint32(in[30])<<16 | uint32(in[31])<<24
|
||||||
|
j8 := uint32(in[32]) | uint32(in[33])<<8 | uint32(in[34])<<16 | uint32(in[35])<<24
|
||||||
|
j9 := uint32(in[36]) | uint32(in[37])<<8 | uint32(in[38])<<16 | uint32(in[39])<<24
|
||||||
|
j10 := uint32(in[40]) | uint32(in[41])<<8 | uint32(in[42])<<16 | uint32(in[43])<<24
|
||||||
|
j11 := uint32(in[44]) | uint32(in[45])<<8 | uint32(in[46])<<16 | uint32(in[47])<<24
|
||||||
|
j12 := uint32(in[48]) | uint32(in[49])<<8 | uint32(in[50])<<16 | uint32(in[51])<<24
|
||||||
|
j13 := uint32(in[52]) | uint32(in[53])<<8 | uint32(in[54])<<16 | uint32(in[55])<<24
|
||||||
|
j14 := uint32(in[56]) | uint32(in[57])<<8 | uint32(in[58])<<16 | uint32(in[59])<<24
|
||||||
|
j15 := uint32(in[60]) | uint32(in[61])<<8 | uint32(in[62])<<16 | uint32(in[63])<<24
|
||||||
|
|
||||||
|
x0, x1, x2, x3, x4, x5, x6, x7, x8 := j0, j1, j2, j3, j4, j5, j6, j7, j8
|
||||||
|
x9, x10, x11, x12, x13, x14, x15 := j9, j10, j11, j12, j13, j14, j15
|
||||||
|
|
||||||
|
for i := 0; i < 8; i += 2 {
|
||||||
|
u := x0 + x12
|
||||||
|
x4 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x4 + x0
|
||||||
|
x8 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x8 + x4
|
||||||
|
x12 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x12 + x8
|
||||||
|
x0 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x5 + x1
|
||||||
|
x9 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x9 + x5
|
||||||
|
x13 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x13 + x9
|
||||||
|
x1 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x1 + x13
|
||||||
|
x5 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x10 + x6
|
||||||
|
x14 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x14 + x10
|
||||||
|
x2 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x2 + x14
|
||||||
|
x6 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x6 + x2
|
||||||
|
x10 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x15 + x11
|
||||||
|
x3 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x3 + x15
|
||||||
|
x7 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x7 + x3
|
||||||
|
x11 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x11 + x7
|
||||||
|
x15 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x0 + x3
|
||||||
|
x1 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x1 + x0
|
||||||
|
x2 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x2 + x1
|
||||||
|
x3 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x3 + x2
|
||||||
|
x0 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x5 + x4
|
||||||
|
x6 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x6 + x5
|
||||||
|
x7 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x7 + x6
|
||||||
|
x4 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x4 + x7
|
||||||
|
x5 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x10 + x9
|
||||||
|
x11 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x11 + x10
|
||||||
|
x8 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x8 + x11
|
||||||
|
x9 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x9 + x8
|
||||||
|
x10 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x15 + x14
|
||||||
|
x12 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x12 + x15
|
||||||
|
x13 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x13 + x12
|
||||||
|
x14 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x14 + x13
|
||||||
|
x15 ^= u<<18 | u>>(32-18)
|
||||||
|
}
|
||||||
|
x0 += j0
|
||||||
|
x1 += j1
|
||||||
|
x2 += j2
|
||||||
|
x3 += j3
|
||||||
|
x4 += j4
|
||||||
|
x5 += j5
|
||||||
|
x6 += j6
|
||||||
|
x7 += j7
|
||||||
|
x8 += j8
|
||||||
|
x9 += j9
|
||||||
|
x10 += j10
|
||||||
|
x11 += j11
|
||||||
|
x12 += j12
|
||||||
|
x13 += j13
|
||||||
|
x14 += j14
|
||||||
|
x15 += j15
|
||||||
|
|
||||||
|
out[0] = byte(x0)
|
||||||
|
out[1] = byte(x0 >> 8)
|
||||||
|
out[2] = byte(x0 >> 16)
|
||||||
|
out[3] = byte(x0 >> 24)
|
||||||
|
|
||||||
|
out[4] = byte(x1)
|
||||||
|
out[5] = byte(x1 >> 8)
|
||||||
|
out[6] = byte(x1 >> 16)
|
||||||
|
out[7] = byte(x1 >> 24)
|
||||||
|
|
||||||
|
out[8] = byte(x2)
|
||||||
|
out[9] = byte(x2 >> 8)
|
||||||
|
out[10] = byte(x2 >> 16)
|
||||||
|
out[11] = byte(x2 >> 24)
|
||||||
|
|
||||||
|
out[12] = byte(x3)
|
||||||
|
out[13] = byte(x3 >> 8)
|
||||||
|
out[14] = byte(x3 >> 16)
|
||||||
|
out[15] = byte(x3 >> 24)
|
||||||
|
|
||||||
|
out[16] = byte(x4)
|
||||||
|
out[17] = byte(x4 >> 8)
|
||||||
|
out[18] = byte(x4 >> 16)
|
||||||
|
out[19] = byte(x4 >> 24)
|
||||||
|
|
||||||
|
out[20] = byte(x5)
|
||||||
|
out[21] = byte(x5 >> 8)
|
||||||
|
out[22] = byte(x5 >> 16)
|
||||||
|
out[23] = byte(x5 >> 24)
|
||||||
|
|
||||||
|
out[24] = byte(x6)
|
||||||
|
out[25] = byte(x6 >> 8)
|
||||||
|
out[26] = byte(x6 >> 16)
|
||||||
|
out[27] = byte(x6 >> 24)
|
||||||
|
|
||||||
|
out[28] = byte(x7)
|
||||||
|
out[29] = byte(x7 >> 8)
|
||||||
|
out[30] = byte(x7 >> 16)
|
||||||
|
out[31] = byte(x7 >> 24)
|
||||||
|
|
||||||
|
out[32] = byte(x8)
|
||||||
|
out[33] = byte(x8 >> 8)
|
||||||
|
out[34] = byte(x8 >> 16)
|
||||||
|
out[35] = byte(x8 >> 24)
|
||||||
|
|
||||||
|
out[36] = byte(x9)
|
||||||
|
out[37] = byte(x9 >> 8)
|
||||||
|
out[38] = byte(x9 >> 16)
|
||||||
|
out[39] = byte(x9 >> 24)
|
||||||
|
|
||||||
|
out[40] = byte(x10)
|
||||||
|
out[41] = byte(x10 >> 8)
|
||||||
|
out[42] = byte(x10 >> 16)
|
||||||
|
out[43] = byte(x10 >> 24)
|
||||||
|
|
||||||
|
out[44] = byte(x11)
|
||||||
|
out[45] = byte(x11 >> 8)
|
||||||
|
out[46] = byte(x11 >> 16)
|
||||||
|
out[47] = byte(x11 >> 24)
|
||||||
|
|
||||||
|
out[48] = byte(x12)
|
||||||
|
out[49] = byte(x12 >> 8)
|
||||||
|
out[50] = byte(x12 >> 16)
|
||||||
|
out[51] = byte(x12 >> 24)
|
||||||
|
|
||||||
|
out[52] = byte(x13)
|
||||||
|
out[53] = byte(x13 >> 8)
|
||||||
|
out[54] = byte(x13 >> 16)
|
||||||
|
out[55] = byte(x13 >> 24)
|
||||||
|
|
||||||
|
out[56] = byte(x14)
|
||||||
|
out[57] = byte(x14 >> 8)
|
||||||
|
out[58] = byte(x14 >> 16)
|
||||||
|
out[59] = byte(x14 >> 24)
|
||||||
|
|
||||||
|
out[60] = byte(x15)
|
||||||
|
out[61] = byte(x15 >> 8)
|
||||||
|
out[62] = byte(x15 >> 16)
|
||||||
|
out[63] = byte(x15 >> 24)
|
||||||
|
}
|
24
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go
generated
vendored
Normal file
24
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
//go:build amd64 && !purego && gc
|
||||||
|
// +build amd64,!purego,gc
|
||||||
|
|
||||||
|
package salsa
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
|
||||||
|
// salsa2020XORKeyStream is implemented in salsa20_amd64.s.
|
||||||
|
func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte)
|
||||||
|
|
||||||
|
// XORKeyStream crypts bytes from in to out using the given key and counters.
|
||||||
|
// In and out must overlap entirely or not at all. Counter
|
||||||
|
// contains the raw salsa20 counter bytes (both nonce and block counter).
|
||||||
|
func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
|
||||||
|
if len(in) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_ = out[len(in)-1]
|
||||||
|
salsa2020XORKeyStream(&out[0], &in[0], uint64(len(in)), &counter[0], &key[0])
|
||||||
|
}
|
881
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.s
generated
vendored
Normal file
881
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,881 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
//go:build amd64 && !purego && gc
|
||||||
|
// +build amd64,!purego,gc
|
||||||
|
|
||||||
|
// This code was translated into a form compatible with 6a from the public
|
||||||
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
|
// func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte)
|
||||||
|
// This needs up to 64 bytes at 360(R12); hence the non-obvious frame size.
|
||||||
|
TEXT ·salsa2020XORKeyStream(SB),0,$456-40 // frame = 424 + 32 byte alignment
|
||||||
|
MOVQ out+0(FP),DI
|
||||||
|
MOVQ in+8(FP),SI
|
||||||
|
MOVQ n+16(FP),DX
|
||||||
|
MOVQ nonce+24(FP),CX
|
||||||
|
MOVQ key+32(FP),R8
|
||||||
|
|
||||||
|
MOVQ SP,R12
|
||||||
|
ADDQ $31, R12
|
||||||
|
ANDQ $~31, R12
|
||||||
|
|
||||||
|
MOVQ DX,R9
|
||||||
|
MOVQ CX,DX
|
||||||
|
MOVQ R8,R10
|
||||||
|
CMPQ R9,$0
|
||||||
|
JBE DONE
|
||||||
|
START:
|
||||||
|
MOVL 20(R10),CX
|
||||||
|
MOVL 0(R10),R8
|
||||||
|
MOVL 0(DX),AX
|
||||||
|
MOVL 16(R10),R11
|
||||||
|
MOVL CX,0(R12)
|
||||||
|
MOVL R8, 4 (R12)
|
||||||
|
MOVL AX, 8 (R12)
|
||||||
|
MOVL R11, 12 (R12)
|
||||||
|
MOVL 8(DX),CX
|
||||||
|
MOVL 24(R10),R8
|
||||||
|
MOVL 4(R10),AX
|
||||||
|
MOVL 4(DX),R11
|
||||||
|
MOVL CX,16(R12)
|
||||||
|
MOVL R8, 20 (R12)
|
||||||
|
MOVL AX, 24 (R12)
|
||||||
|
MOVL R11, 28 (R12)
|
||||||
|
MOVL 12(DX),CX
|
||||||
|
MOVL 12(R10),DX
|
||||||
|
MOVL 28(R10),R8
|
||||||
|
MOVL 8(R10),AX
|
||||||
|
MOVL DX,32(R12)
|
||||||
|
MOVL CX, 36 (R12)
|
||||||
|
MOVL R8, 40 (R12)
|
||||||
|
MOVL AX, 44 (R12)
|
||||||
|
MOVQ $1634760805,DX
|
||||||
|
MOVQ $857760878,CX
|
||||||
|
MOVQ $2036477234,R8
|
||||||
|
MOVQ $1797285236,AX
|
||||||
|
MOVL DX,48(R12)
|
||||||
|
MOVL CX, 52 (R12)
|
||||||
|
MOVL R8, 56 (R12)
|
||||||
|
MOVL AX, 60 (R12)
|
||||||
|
CMPQ R9,$256
|
||||||
|
JB BYTESBETWEEN1AND255
|
||||||
|
MOVOA 48(R12),X0
|
||||||
|
PSHUFL $0X55,X0,X1
|
||||||
|
PSHUFL $0XAA,X0,X2
|
||||||
|
PSHUFL $0XFF,X0,X3
|
||||||
|
PSHUFL $0X00,X0,X0
|
||||||
|
MOVOA X1,64(R12)
|
||||||
|
MOVOA X2,80(R12)
|
||||||
|
MOVOA X3,96(R12)
|
||||||
|
MOVOA X0,112(R12)
|
||||||
|
MOVOA 0(R12),X0
|
||||||
|
PSHUFL $0XAA,X0,X1
|
||||||
|
PSHUFL $0XFF,X0,X2
|
||||||
|
PSHUFL $0X00,X0,X3
|
||||||
|
PSHUFL $0X55,X0,X0
|
||||||
|
MOVOA X1,128(R12)
|
||||||
|
MOVOA X2,144(R12)
|
||||||
|
MOVOA X3,160(R12)
|
||||||
|
MOVOA X0,176(R12)
|
||||||
|
MOVOA 16(R12),X0
|
||||||
|
PSHUFL $0XFF,X0,X1
|
||||||
|
PSHUFL $0X55,X0,X2
|
||||||
|
PSHUFL $0XAA,X0,X0
|
||||||
|
MOVOA X1,192(R12)
|
||||||
|
MOVOA X2,208(R12)
|
||||||
|
MOVOA X0,224(R12)
|
||||||
|
MOVOA 32(R12),X0
|
||||||
|
PSHUFL $0X00,X0,X1
|
||||||
|
PSHUFL $0XAA,X0,X2
|
||||||
|
PSHUFL $0XFF,X0,X0
|
||||||
|
MOVOA X1,240(R12)
|
||||||
|
MOVOA X2,256(R12)
|
||||||
|
MOVOA X0,272(R12)
|
||||||
|
BYTESATLEAST256:
|
||||||
|
MOVL 16(R12),DX
|
||||||
|
MOVL 36 (R12),CX
|
||||||
|
MOVL DX,288(R12)
|
||||||
|
MOVL CX,304(R12)
|
||||||
|
SHLQ $32,CX
|
||||||
|
ADDQ CX,DX
|
||||||
|
ADDQ $1,DX
|
||||||
|
MOVQ DX,CX
|
||||||
|
SHRQ $32,CX
|
||||||
|
MOVL DX, 292 (R12)
|
||||||
|
MOVL CX, 308 (R12)
|
||||||
|
ADDQ $1,DX
|
||||||
|
MOVQ DX,CX
|
||||||
|
SHRQ $32,CX
|
||||||
|
MOVL DX, 296 (R12)
|
||||||
|
MOVL CX, 312 (R12)
|
||||||
|
ADDQ $1,DX
|
||||||
|
MOVQ DX,CX
|
||||||
|
SHRQ $32,CX
|
||||||
|
MOVL DX, 300 (R12)
|
||||||
|
MOVL CX, 316 (R12)
|
||||||
|
ADDQ $1,DX
|
||||||
|
MOVQ DX,CX
|
||||||
|
SHRQ $32,CX
|
||||||
|
MOVL DX,16(R12)
|
||||||
|
MOVL CX, 36 (R12)
|
||||||
|
MOVQ R9,352(R12)
|
||||||
|
MOVQ $20,DX
|
||||||
|
MOVOA 64(R12),X0
|
||||||
|
MOVOA 80(R12),X1
|
||||||
|
MOVOA 96(R12),X2
|
||||||
|
MOVOA 256(R12),X3
|
||||||
|
MOVOA 272(R12),X4
|
||||||
|
MOVOA 128(R12),X5
|
||||||
|
MOVOA 144(R12),X6
|
||||||
|
MOVOA 176(R12),X7
|
||||||
|
MOVOA 192(R12),X8
|
||||||
|
MOVOA 208(R12),X9
|
||||||
|
MOVOA 224(R12),X10
|
||||||
|
MOVOA 304(R12),X11
|
||||||
|
MOVOA 112(R12),X12
|
||||||
|
MOVOA 160(R12),X13
|
||||||
|
MOVOA 240(R12),X14
|
||||||
|
MOVOA 288(R12),X15
|
||||||
|
MAINLOOP1:
|
||||||
|
MOVOA X1,320(R12)
|
||||||
|
MOVOA X2,336(R12)
|
||||||
|
MOVOA X13,X1
|
||||||
|
PADDL X12,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $7,X1
|
||||||
|
PXOR X1,X14
|
||||||
|
PSRLL $25,X2
|
||||||
|
PXOR X2,X14
|
||||||
|
MOVOA X7,X1
|
||||||
|
PADDL X0,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $7,X1
|
||||||
|
PXOR X1,X11
|
||||||
|
PSRLL $25,X2
|
||||||
|
PXOR X2,X11
|
||||||
|
MOVOA X12,X1
|
||||||
|
PADDL X14,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $9,X1
|
||||||
|
PXOR X1,X15
|
||||||
|
PSRLL $23,X2
|
||||||
|
PXOR X2,X15
|
||||||
|
MOVOA X0,X1
|
||||||
|
PADDL X11,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $9,X1
|
||||||
|
PXOR X1,X9
|
||||||
|
PSRLL $23,X2
|
||||||
|
PXOR X2,X9
|
||||||
|
MOVOA X14,X1
|
||||||
|
PADDL X15,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $13,X1
|
||||||
|
PXOR X1,X13
|
||||||
|
PSRLL $19,X2
|
||||||
|
PXOR X2,X13
|
||||||
|
MOVOA X11,X1
|
||||||
|
PADDL X9,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $13,X1
|
||||||
|
PXOR X1,X7
|
||||||
|
PSRLL $19,X2
|
||||||
|
PXOR X2,X7
|
||||||
|
MOVOA X15,X1
|
||||||
|
PADDL X13,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $18,X1
|
||||||
|
PXOR X1,X12
|
||||||
|
PSRLL $14,X2
|
||||||
|
PXOR X2,X12
|
||||||
|
MOVOA 320(R12),X1
|
||||||
|
MOVOA X12,320(R12)
|
||||||
|
MOVOA X9,X2
|
||||||
|
PADDL X7,X2
|
||||||
|
MOVOA X2,X12
|
||||||
|
PSLLL $18,X2
|
||||||
|
PXOR X2,X0
|
||||||
|
PSRLL $14,X12
|
||||||
|
PXOR X12,X0
|
||||||
|
MOVOA X5,X2
|
||||||
|
PADDL X1,X2
|
||||||
|
MOVOA X2,X12
|
||||||
|
PSLLL $7,X2
|
||||||
|
PXOR X2,X3
|
||||||
|
PSRLL $25,X12
|
||||||
|
PXOR X12,X3
|
||||||
|
MOVOA 336(R12),X2
|
||||||
|
MOVOA X0,336(R12)
|
||||||
|
MOVOA X6,X0
|
||||||
|
PADDL X2,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $7,X0
|
||||||
|
PXOR X0,X4
|
||||||
|
PSRLL $25,X12
|
||||||
|
PXOR X12,X4
|
||||||
|
MOVOA X1,X0
|
||||||
|
PADDL X3,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $9,X0
|
||||||
|
PXOR X0,X10
|
||||||
|
PSRLL $23,X12
|
||||||
|
PXOR X12,X10
|
||||||
|
MOVOA X2,X0
|
||||||
|
PADDL X4,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $9,X0
|
||||||
|
PXOR X0,X8
|
||||||
|
PSRLL $23,X12
|
||||||
|
PXOR X12,X8
|
||||||
|
MOVOA X3,X0
|
||||||
|
PADDL X10,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $13,X0
|
||||||
|
PXOR X0,X5
|
||||||
|
PSRLL $19,X12
|
||||||
|
PXOR X12,X5
|
||||||
|
MOVOA X4,X0
|
||||||
|
PADDL X8,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $13,X0
|
||||||
|
PXOR X0,X6
|
||||||
|
PSRLL $19,X12
|
||||||
|
PXOR X12,X6
|
||||||
|
MOVOA X10,X0
|
||||||
|
PADDL X5,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $18,X0
|
||||||
|
PXOR X0,X1
|
||||||
|
PSRLL $14,X12
|
||||||
|
PXOR X12,X1
|
||||||
|
MOVOA 320(R12),X0
|
||||||
|
MOVOA X1,320(R12)
|
||||||
|
MOVOA X4,X1
|
||||||
|
PADDL X0,X1
|
||||||
|
MOVOA X1,X12
|
||||||
|
PSLLL $7,X1
|
||||||
|
PXOR X1,X7
|
||||||
|
PSRLL $25,X12
|
||||||
|
PXOR X12,X7
|
||||||
|
MOVOA X8,X1
|
||||||
|
PADDL X6,X1
|
||||||
|
MOVOA X1,X12
|
||||||
|
PSLLL $18,X1
|
||||||
|
PXOR X1,X2
|
||||||
|
PSRLL $14,X12
|
||||||
|
PXOR X12,X2
|
||||||
|
MOVOA 336(R12),X12
|
||||||
|
MOVOA X2,336(R12)
|
||||||
|
MOVOA X14,X1
|
||||||
|
PADDL X12,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $7,X1
|
||||||
|
PXOR X1,X5
|
||||||
|
PSRLL $25,X2
|
||||||
|
PXOR X2,X5
|
||||||
|
MOVOA X0,X1
|
||||||
|
PADDL X7,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $9,X1
|
||||||
|
PXOR X1,X10
|
||||||
|
PSRLL $23,X2
|
||||||
|
PXOR X2,X10
|
||||||
|
MOVOA X12,X1
|
||||||
|
PADDL X5,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $9,X1
|
||||||
|
PXOR X1,X8
|
||||||
|
PSRLL $23,X2
|
||||||
|
PXOR X2,X8
|
||||||
|
MOVOA X7,X1
|
||||||
|
PADDL X10,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $13,X1
|
||||||
|
PXOR X1,X4
|
||||||
|
PSRLL $19,X2
|
||||||
|
PXOR X2,X4
|
||||||
|
MOVOA X5,X1
|
||||||
|
PADDL X8,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $13,X1
|
||||||
|
PXOR X1,X14
|
||||||
|
PSRLL $19,X2
|
||||||
|
PXOR X2,X14
|
||||||
|
MOVOA X10,X1
|
||||||
|
PADDL X4,X1
|
||||||
|
MOVOA X1,X2
|
||||||
|
PSLLL $18,X1
|
||||||
|
PXOR X1,X0
|
||||||
|
PSRLL $14,X2
|
||||||
|
PXOR X2,X0
|
||||||
|
MOVOA 320(R12),X1
|
||||||
|
MOVOA X0,320(R12)
|
||||||
|
MOVOA X8,X0
|
||||||
|
PADDL X14,X0
|
||||||
|
MOVOA X0,X2
|
||||||
|
PSLLL $18,X0
|
||||||
|
PXOR X0,X12
|
||||||
|
PSRLL $14,X2
|
||||||
|
PXOR X2,X12
|
||||||
|
MOVOA X11,X0
|
||||||
|
PADDL X1,X0
|
||||||
|
MOVOA X0,X2
|
||||||
|
PSLLL $7,X0
|
||||||
|
PXOR X0,X6
|
||||||
|
PSRLL $25,X2
|
||||||
|
PXOR X2,X6
|
||||||
|
MOVOA 336(R12),X2
|
||||||
|
MOVOA X12,336(R12)
|
||||||
|
MOVOA X3,X0
|
||||||
|
PADDL X2,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $7,X0
|
||||||
|
PXOR X0,X13
|
||||||
|
PSRLL $25,X12
|
||||||
|
PXOR X12,X13
|
||||||
|
MOVOA X1,X0
|
||||||
|
PADDL X6,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $9,X0
|
||||||
|
PXOR X0,X15
|
||||||
|
PSRLL $23,X12
|
||||||
|
PXOR X12,X15
|
||||||
|
MOVOA X2,X0
|
||||||
|
PADDL X13,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $9,X0
|
||||||
|
PXOR X0,X9
|
||||||
|
PSRLL $23,X12
|
||||||
|
PXOR X12,X9
|
||||||
|
MOVOA X6,X0
|
||||||
|
PADDL X15,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $13,X0
|
||||||
|
PXOR X0,X11
|
||||||
|
PSRLL $19,X12
|
||||||
|
PXOR X12,X11
|
||||||
|
MOVOA X13,X0
|
||||||
|
PADDL X9,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $13,X0
|
||||||
|
PXOR X0,X3
|
||||||
|
PSRLL $19,X12
|
||||||
|
PXOR X12,X3
|
||||||
|
MOVOA X15,X0
|
||||||
|
PADDL X11,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $18,X0
|
||||||
|
PXOR X0,X1
|
||||||
|
PSRLL $14,X12
|
||||||
|
PXOR X12,X1
|
||||||
|
MOVOA X9,X0
|
||||||
|
PADDL X3,X0
|
||||||
|
MOVOA X0,X12
|
||||||
|
PSLLL $18,X0
|
||||||
|
PXOR X0,X2
|
||||||
|
PSRLL $14,X12
|
||||||
|
PXOR X12,X2
|
||||||
|
MOVOA 320(R12),X12
|
||||||
|
MOVOA 336(R12),X0
|
||||||
|
SUBQ $2,DX
|
||||||
|
JA MAINLOOP1
|
||||||
|
PADDL 112(R12),X12
|
||||||
|
PADDL 176(R12),X7
|
||||||
|
PADDL 224(R12),X10
|
||||||
|
PADDL 272(R12),X4
|
||||||
|
MOVD X12,DX
|
||||||
|
MOVD X7,CX
|
||||||
|
MOVD X10,R8
|
||||||
|
MOVD X4,R9
|
||||||
|
PSHUFL $0X39,X12,X12
|
||||||
|
PSHUFL $0X39,X7,X7
|
||||||
|
PSHUFL $0X39,X10,X10
|
||||||
|
PSHUFL $0X39,X4,X4
|
||||||
|
XORL 0(SI),DX
|
||||||
|
XORL 4(SI),CX
|
||||||
|
XORL 8(SI),R8
|
||||||
|
XORL 12(SI),R9
|
||||||
|
MOVL DX,0(DI)
|
||||||
|
MOVL CX,4(DI)
|
||||||
|
MOVL R8,8(DI)
|
||||||
|
MOVL R9,12(DI)
|
||||||
|
MOVD X12,DX
|
||||||
|
MOVD X7,CX
|
||||||
|
MOVD X10,R8
|
||||||
|
MOVD X4,R9
|
||||||
|
PSHUFL $0X39,X12,X12
|
||||||
|
PSHUFL $0X39,X7,X7
|
||||||
|
PSHUFL $0X39,X10,X10
|
||||||
|
PSHUFL $0X39,X4,X4
|
||||||
|
XORL 64(SI),DX
|
||||||
|
XORL 68(SI),CX
|
||||||
|
XORL 72(SI),R8
|
||||||
|
XORL 76(SI),R9
|
||||||
|
MOVL DX,64(DI)
|
||||||
|
MOVL CX,68(DI)
|
||||||
|
MOVL R8,72(DI)
|
||||||
|
MOVL R9,76(DI)
|
||||||
|
MOVD X12,DX
|
||||||
|
MOVD X7,CX
|
||||||
|
MOVD X10,R8
|
||||||
|
MOVD X4,R9
|
||||||
|
PSHUFL $0X39,X12,X12
|
||||||
|
PSHUFL $0X39,X7,X7
|
||||||
|
PSHUFL $0X39,X10,X10
|
||||||
|
PSHUFL $0X39,X4,X4
|
||||||
|
XORL 128(SI),DX
|
||||||
|
XORL 132(SI),CX
|
||||||
|
XORL 136(SI),R8
|
||||||
|
XORL 140(SI),R9
|
||||||
|
MOVL DX,128(DI)
|
||||||
|
MOVL CX,132(DI)
|
||||||
|
MOVL R8,136(DI)
|
||||||
|
MOVL R9,140(DI)
|
||||||
|
MOVD X12,DX
|
||||||
|
MOVD X7,CX
|
||||||
|
MOVD X10,R8
|
||||||
|
MOVD X4,R9
|
||||||
|
XORL 192(SI),DX
|
||||||
|
XORL 196(SI),CX
|
||||||
|
XORL 200(SI),R8
|
||||||
|
XORL 204(SI),R9
|
||||||
|
MOVL DX,192(DI)
|
||||||
|
MOVL CX,196(DI)
|
||||||
|
MOVL R8,200(DI)
|
||||||
|
MOVL R9,204(DI)
|
||||||
|
PADDL 240(R12),X14
|
||||||
|
PADDL 64(R12),X0
|
||||||
|
PADDL 128(R12),X5
|
||||||
|
PADDL 192(R12),X8
|
||||||
|
MOVD X14,DX
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X5,R8
|
||||||
|
MOVD X8,R9
|
||||||
|
PSHUFL $0X39,X14,X14
|
||||||
|
PSHUFL $0X39,X0,X0
|
||||||
|
PSHUFL $0X39,X5,X5
|
||||||
|
PSHUFL $0X39,X8,X8
|
||||||
|
XORL 16(SI),DX
|
||||||
|
XORL 20(SI),CX
|
||||||
|
XORL 24(SI),R8
|
||||||
|
XORL 28(SI),R9
|
||||||
|
MOVL DX,16(DI)
|
||||||
|
MOVL CX,20(DI)
|
||||||
|
MOVL R8,24(DI)
|
||||||
|
MOVL R9,28(DI)
|
||||||
|
MOVD X14,DX
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X5,R8
|
||||||
|
MOVD X8,R9
|
||||||
|
PSHUFL $0X39,X14,X14
|
||||||
|
PSHUFL $0X39,X0,X0
|
||||||
|
PSHUFL $0X39,X5,X5
|
||||||
|
PSHUFL $0X39,X8,X8
|
||||||
|
XORL 80(SI),DX
|
||||||
|
XORL 84(SI),CX
|
||||||
|
XORL 88(SI),R8
|
||||||
|
XORL 92(SI),R9
|
||||||
|
MOVL DX,80(DI)
|
||||||
|
MOVL CX,84(DI)
|
||||||
|
MOVL R8,88(DI)
|
||||||
|
MOVL R9,92(DI)
|
||||||
|
MOVD X14,DX
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X5,R8
|
||||||
|
MOVD X8,R9
|
||||||
|
PSHUFL $0X39,X14,X14
|
||||||
|
PSHUFL $0X39,X0,X0
|
||||||
|
PSHUFL $0X39,X5,X5
|
||||||
|
PSHUFL $0X39,X8,X8
|
||||||
|
XORL 144(SI),DX
|
||||||
|
XORL 148(SI),CX
|
||||||
|
XORL 152(SI),R8
|
||||||
|
XORL 156(SI),R9
|
||||||
|
MOVL DX,144(DI)
|
||||||
|
MOVL CX,148(DI)
|
||||||
|
MOVL R8,152(DI)
|
||||||
|
MOVL R9,156(DI)
|
||||||
|
MOVD X14,DX
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X5,R8
|
||||||
|
MOVD X8,R9
|
||||||
|
XORL 208(SI),DX
|
||||||
|
XORL 212(SI),CX
|
||||||
|
XORL 216(SI),R8
|
||||||
|
XORL 220(SI),R9
|
||||||
|
MOVL DX,208(DI)
|
||||||
|
MOVL CX,212(DI)
|
||||||
|
MOVL R8,216(DI)
|
||||||
|
MOVL R9,220(DI)
|
||||||
|
PADDL 288(R12),X15
|
||||||
|
PADDL 304(R12),X11
|
||||||
|
PADDL 80(R12),X1
|
||||||
|
PADDL 144(R12),X6
|
||||||
|
MOVD X15,DX
|
||||||
|
MOVD X11,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X6,R9
|
||||||
|
PSHUFL $0X39,X15,X15
|
||||||
|
PSHUFL $0X39,X11,X11
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PSHUFL $0X39,X6,X6
|
||||||
|
XORL 32(SI),DX
|
||||||
|
XORL 36(SI),CX
|
||||||
|
XORL 40(SI),R8
|
||||||
|
XORL 44(SI),R9
|
||||||
|
MOVL DX,32(DI)
|
||||||
|
MOVL CX,36(DI)
|
||||||
|
MOVL R8,40(DI)
|
||||||
|
MOVL R9,44(DI)
|
||||||
|
MOVD X15,DX
|
||||||
|
MOVD X11,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X6,R9
|
||||||
|
PSHUFL $0X39,X15,X15
|
||||||
|
PSHUFL $0X39,X11,X11
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PSHUFL $0X39,X6,X6
|
||||||
|
XORL 96(SI),DX
|
||||||
|
XORL 100(SI),CX
|
||||||
|
XORL 104(SI),R8
|
||||||
|
XORL 108(SI),R9
|
||||||
|
MOVL DX,96(DI)
|
||||||
|
MOVL CX,100(DI)
|
||||||
|
MOVL R8,104(DI)
|
||||||
|
MOVL R9,108(DI)
|
||||||
|
MOVD X15,DX
|
||||||
|
MOVD X11,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X6,R9
|
||||||
|
PSHUFL $0X39,X15,X15
|
||||||
|
PSHUFL $0X39,X11,X11
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PSHUFL $0X39,X6,X6
|
||||||
|
XORL 160(SI),DX
|
||||||
|
XORL 164(SI),CX
|
||||||
|
XORL 168(SI),R8
|
||||||
|
XORL 172(SI),R9
|
||||||
|
MOVL DX,160(DI)
|
||||||
|
MOVL CX,164(DI)
|
||||||
|
MOVL R8,168(DI)
|
||||||
|
MOVL R9,172(DI)
|
||||||
|
MOVD X15,DX
|
||||||
|
MOVD X11,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X6,R9
|
||||||
|
XORL 224(SI),DX
|
||||||
|
XORL 228(SI),CX
|
||||||
|
XORL 232(SI),R8
|
||||||
|
XORL 236(SI),R9
|
||||||
|
MOVL DX,224(DI)
|
||||||
|
MOVL CX,228(DI)
|
||||||
|
MOVL R8,232(DI)
|
||||||
|
MOVL R9,236(DI)
|
||||||
|
PADDL 160(R12),X13
|
||||||
|
PADDL 208(R12),X9
|
||||||
|
PADDL 256(R12),X3
|
||||||
|
PADDL 96(R12),X2
|
||||||
|
MOVD X13,DX
|
||||||
|
MOVD X9,CX
|
||||||
|
MOVD X3,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
PSHUFL $0X39,X13,X13
|
||||||
|
PSHUFL $0X39,X9,X9
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
PSHUFL $0X39,X2,X2
|
||||||
|
XORL 48(SI),DX
|
||||||
|
XORL 52(SI),CX
|
||||||
|
XORL 56(SI),R8
|
||||||
|
XORL 60(SI),R9
|
||||||
|
MOVL DX,48(DI)
|
||||||
|
MOVL CX,52(DI)
|
||||||
|
MOVL R8,56(DI)
|
||||||
|
MOVL R9,60(DI)
|
||||||
|
MOVD X13,DX
|
||||||
|
MOVD X9,CX
|
||||||
|
MOVD X3,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
PSHUFL $0X39,X13,X13
|
||||||
|
PSHUFL $0X39,X9,X9
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
PSHUFL $0X39,X2,X2
|
||||||
|
XORL 112(SI),DX
|
||||||
|
XORL 116(SI),CX
|
||||||
|
XORL 120(SI),R8
|
||||||
|
XORL 124(SI),R9
|
||||||
|
MOVL DX,112(DI)
|
||||||
|
MOVL CX,116(DI)
|
||||||
|
MOVL R8,120(DI)
|
||||||
|
MOVL R9,124(DI)
|
||||||
|
MOVD X13,DX
|
||||||
|
MOVD X9,CX
|
||||||
|
MOVD X3,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
PSHUFL $0X39,X13,X13
|
||||||
|
PSHUFL $0X39,X9,X9
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
PSHUFL $0X39,X2,X2
|
||||||
|
XORL 176(SI),DX
|
||||||
|
XORL 180(SI),CX
|
||||||
|
XORL 184(SI),R8
|
||||||
|
XORL 188(SI),R9
|
||||||
|
MOVL DX,176(DI)
|
||||||
|
MOVL CX,180(DI)
|
||||||
|
MOVL R8,184(DI)
|
||||||
|
MOVL R9,188(DI)
|
||||||
|
MOVD X13,DX
|
||||||
|
MOVD X9,CX
|
||||||
|
MOVD X3,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
XORL 240(SI),DX
|
||||||
|
XORL 244(SI),CX
|
||||||
|
XORL 248(SI),R8
|
||||||
|
XORL 252(SI),R9
|
||||||
|
MOVL DX,240(DI)
|
||||||
|
MOVL CX,244(DI)
|
||||||
|
MOVL R8,248(DI)
|
||||||
|
MOVL R9,252(DI)
|
||||||
|
MOVQ 352(R12),R9
|
||||||
|
SUBQ $256,R9
|
||||||
|
ADDQ $256,SI
|
||||||
|
ADDQ $256,DI
|
||||||
|
CMPQ R9,$256
|
||||||
|
JAE BYTESATLEAST256
|
||||||
|
CMPQ R9,$0
|
||||||
|
JBE DONE
|
||||||
|
BYTESBETWEEN1AND255:
|
||||||
|
CMPQ R9,$64
|
||||||
|
JAE NOCOPY
|
||||||
|
MOVQ DI,DX
|
||||||
|
LEAQ 360(R12),DI
|
||||||
|
MOVQ R9,CX
|
||||||
|
REP; MOVSB
|
||||||
|
LEAQ 360(R12),DI
|
||||||
|
LEAQ 360(R12),SI
|
||||||
|
NOCOPY:
|
||||||
|
MOVQ R9,352(R12)
|
||||||
|
MOVOA 48(R12),X0
|
||||||
|
MOVOA 0(R12),X1
|
||||||
|
MOVOA 16(R12),X2
|
||||||
|
MOVOA 32(R12),X3
|
||||||
|
MOVOA X1,X4
|
||||||
|
MOVQ $20,CX
|
||||||
|
MAINLOOP2:
|
||||||
|
PADDL X0,X4
|
||||||
|
MOVOA X0,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $7,X4
|
||||||
|
PSRLL $25,X6
|
||||||
|
PXOR X4,X3
|
||||||
|
PXOR X6,X3
|
||||||
|
PADDL X3,X5
|
||||||
|
MOVOA X3,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $9,X5
|
||||||
|
PSRLL $23,X6
|
||||||
|
PXOR X5,X2
|
||||||
|
PSHUFL $0X93,X3,X3
|
||||||
|
PXOR X6,X2
|
||||||
|
PADDL X2,X4
|
||||||
|
MOVOA X2,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $13,X4
|
||||||
|
PSRLL $19,X6
|
||||||
|
PXOR X4,X1
|
||||||
|
PSHUFL $0X4E,X2,X2
|
||||||
|
PXOR X6,X1
|
||||||
|
PADDL X1,X5
|
||||||
|
MOVOA X3,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $18,X5
|
||||||
|
PSRLL $14,X6
|
||||||
|
PXOR X5,X0
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PXOR X6,X0
|
||||||
|
PADDL X0,X4
|
||||||
|
MOVOA X0,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $7,X4
|
||||||
|
PSRLL $25,X6
|
||||||
|
PXOR X4,X1
|
||||||
|
PXOR X6,X1
|
||||||
|
PADDL X1,X5
|
||||||
|
MOVOA X1,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $9,X5
|
||||||
|
PSRLL $23,X6
|
||||||
|
PXOR X5,X2
|
||||||
|
PSHUFL $0X93,X1,X1
|
||||||
|
PXOR X6,X2
|
||||||
|
PADDL X2,X4
|
||||||
|
MOVOA X2,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $13,X4
|
||||||
|
PSRLL $19,X6
|
||||||
|
PXOR X4,X3
|
||||||
|
PSHUFL $0X4E,X2,X2
|
||||||
|
PXOR X6,X3
|
||||||
|
PADDL X3,X5
|
||||||
|
MOVOA X1,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $18,X5
|
||||||
|
PSRLL $14,X6
|
||||||
|
PXOR X5,X0
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
PXOR X6,X0
|
||||||
|
PADDL X0,X4
|
||||||
|
MOVOA X0,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $7,X4
|
||||||
|
PSRLL $25,X6
|
||||||
|
PXOR X4,X3
|
||||||
|
PXOR X6,X3
|
||||||
|
PADDL X3,X5
|
||||||
|
MOVOA X3,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $9,X5
|
||||||
|
PSRLL $23,X6
|
||||||
|
PXOR X5,X2
|
||||||
|
PSHUFL $0X93,X3,X3
|
||||||
|
PXOR X6,X2
|
||||||
|
PADDL X2,X4
|
||||||
|
MOVOA X2,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $13,X4
|
||||||
|
PSRLL $19,X6
|
||||||
|
PXOR X4,X1
|
||||||
|
PSHUFL $0X4E,X2,X2
|
||||||
|
PXOR X6,X1
|
||||||
|
PADDL X1,X5
|
||||||
|
MOVOA X3,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $18,X5
|
||||||
|
PSRLL $14,X6
|
||||||
|
PXOR X5,X0
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PXOR X6,X0
|
||||||
|
PADDL X0,X4
|
||||||
|
MOVOA X0,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $7,X4
|
||||||
|
PSRLL $25,X6
|
||||||
|
PXOR X4,X1
|
||||||
|
PXOR X6,X1
|
||||||
|
PADDL X1,X5
|
||||||
|
MOVOA X1,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $9,X5
|
||||||
|
PSRLL $23,X6
|
||||||
|
PXOR X5,X2
|
||||||
|
PSHUFL $0X93,X1,X1
|
||||||
|
PXOR X6,X2
|
||||||
|
PADDL X2,X4
|
||||||
|
MOVOA X2,X5
|
||||||
|
MOVOA X4,X6
|
||||||
|
PSLLL $13,X4
|
||||||
|
PSRLL $19,X6
|
||||||
|
PXOR X4,X3
|
||||||
|
PSHUFL $0X4E,X2,X2
|
||||||
|
PXOR X6,X3
|
||||||
|
SUBQ $4,CX
|
||||||
|
PADDL X3,X5
|
||||||
|
MOVOA X1,X4
|
||||||
|
MOVOA X5,X6
|
||||||
|
PSLLL $18,X5
|
||||||
|
PXOR X7,X7
|
||||||
|
PSRLL $14,X6
|
||||||
|
PXOR X5,X0
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
PXOR X6,X0
|
||||||
|
JA MAINLOOP2
|
||||||
|
PADDL 48(R12),X0
|
||||||
|
PADDL 0(R12),X1
|
||||||
|
PADDL 16(R12),X2
|
||||||
|
PADDL 32(R12),X3
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
MOVD X3,AX
|
||||||
|
PSHUFL $0X39,X0,X0
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PSHUFL $0X39,X2,X2
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
XORL 0(SI),CX
|
||||||
|
XORL 48(SI),R8
|
||||||
|
XORL 32(SI),R9
|
||||||
|
XORL 16(SI),AX
|
||||||
|
MOVL CX,0(DI)
|
||||||
|
MOVL R8,48(DI)
|
||||||
|
MOVL R9,32(DI)
|
||||||
|
MOVL AX,16(DI)
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
MOVD X3,AX
|
||||||
|
PSHUFL $0X39,X0,X0
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PSHUFL $0X39,X2,X2
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
XORL 20(SI),CX
|
||||||
|
XORL 4(SI),R8
|
||||||
|
XORL 52(SI),R9
|
||||||
|
XORL 36(SI),AX
|
||||||
|
MOVL CX,20(DI)
|
||||||
|
MOVL R8,4(DI)
|
||||||
|
MOVL R9,52(DI)
|
||||||
|
MOVL AX,36(DI)
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
MOVD X3,AX
|
||||||
|
PSHUFL $0X39,X0,X0
|
||||||
|
PSHUFL $0X39,X1,X1
|
||||||
|
PSHUFL $0X39,X2,X2
|
||||||
|
PSHUFL $0X39,X3,X3
|
||||||
|
XORL 40(SI),CX
|
||||||
|
XORL 24(SI),R8
|
||||||
|
XORL 8(SI),R9
|
||||||
|
XORL 56(SI),AX
|
||||||
|
MOVL CX,40(DI)
|
||||||
|
MOVL R8,24(DI)
|
||||||
|
MOVL R9,8(DI)
|
||||||
|
MOVL AX,56(DI)
|
||||||
|
MOVD X0,CX
|
||||||
|
MOVD X1,R8
|
||||||
|
MOVD X2,R9
|
||||||
|
MOVD X3,AX
|
||||||
|
XORL 60(SI),CX
|
||||||
|
XORL 44(SI),R8
|
||||||
|
XORL 28(SI),R9
|
||||||
|
XORL 12(SI),AX
|
||||||
|
MOVL CX,60(DI)
|
||||||
|
MOVL R8,44(DI)
|
||||||
|
MOVL R9,28(DI)
|
||||||
|
MOVL AX,12(DI)
|
||||||
|
MOVQ 352(R12),R9
|
||||||
|
MOVL 16(R12),CX
|
||||||
|
MOVL 36 (R12),R8
|
||||||
|
ADDQ $1,CX
|
||||||
|
SHLQ $32,R8
|
||||||
|
ADDQ R8,CX
|
||||||
|
MOVQ CX,R8
|
||||||
|
SHRQ $32,R8
|
||||||
|
MOVL CX,16(R12)
|
||||||
|
MOVL R8, 36 (R12)
|
||||||
|
CMPQ R9,$64
|
||||||
|
JA BYTESATLEAST65
|
||||||
|
JAE BYTESATLEAST64
|
||||||
|
MOVQ DI,SI
|
||||||
|
MOVQ DX,DI
|
||||||
|
MOVQ R9,CX
|
||||||
|
REP; MOVSB
|
||||||
|
BYTESATLEAST64:
|
||||||
|
DONE:
|
||||||
|
RET
|
||||||
|
BYTESATLEAST65:
|
||||||
|
SUBQ $64,R9
|
||||||
|
ADDQ $64,DI
|
||||||
|
ADDQ $64,SI
|
||||||
|
JMP BYTESBETWEEN1AND255
|
15
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.go
generated
vendored
Normal file
15
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.go
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build !amd64 || purego || !gc
|
||||||
|
// +build !amd64 purego !gc
|
||||||
|
|
||||||
|
package salsa
|
||||||
|
|
||||||
|
// XORKeyStream crypts bytes from in to out using the given key and counters.
|
||||||
|
// In and out must overlap entirely or not at all. Counter
|
||||||
|
// contains the raw salsa20 counter bytes (both nonce and block counter).
|
||||||
|
func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
|
||||||
|
genericXORKeyStream(out, in, counter, key)
|
||||||
|
}
|
231
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
generated
vendored
Normal file
231
vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
generated
vendored
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
package salsa
|
||||||
|
|
||||||
|
const rounds = 20
|
||||||
|
|
||||||
|
// core applies the Salsa20 core function to 16-byte input in, 32-byte key k,
|
||||||
|
// and 16-byte constant c, and puts the result into 64-byte array out.
|
||||||
|
func core(out *[64]byte, in *[16]byte, k *[32]byte, c *[16]byte) {
|
||||||
|
j0 := uint32(c[0]) | uint32(c[1])<<8 | uint32(c[2])<<16 | uint32(c[3])<<24
|
||||||
|
j1 := uint32(k[0]) | uint32(k[1])<<8 | uint32(k[2])<<16 | uint32(k[3])<<24
|
||||||
|
j2 := uint32(k[4]) | uint32(k[5])<<8 | uint32(k[6])<<16 | uint32(k[7])<<24
|
||||||
|
j3 := uint32(k[8]) | uint32(k[9])<<8 | uint32(k[10])<<16 | uint32(k[11])<<24
|
||||||
|
j4 := uint32(k[12]) | uint32(k[13])<<8 | uint32(k[14])<<16 | uint32(k[15])<<24
|
||||||
|
j5 := uint32(c[4]) | uint32(c[5])<<8 | uint32(c[6])<<16 | uint32(c[7])<<24
|
||||||
|
j6 := uint32(in[0]) | uint32(in[1])<<8 | uint32(in[2])<<16 | uint32(in[3])<<24
|
||||||
|
j7 := uint32(in[4]) | uint32(in[5])<<8 | uint32(in[6])<<16 | uint32(in[7])<<24
|
||||||
|
j8 := uint32(in[8]) | uint32(in[9])<<8 | uint32(in[10])<<16 | uint32(in[11])<<24
|
||||||
|
j9 := uint32(in[12]) | uint32(in[13])<<8 | uint32(in[14])<<16 | uint32(in[15])<<24
|
||||||
|
j10 := uint32(c[8]) | uint32(c[9])<<8 | uint32(c[10])<<16 | uint32(c[11])<<24
|
||||||
|
j11 := uint32(k[16]) | uint32(k[17])<<8 | uint32(k[18])<<16 | uint32(k[19])<<24
|
||||||
|
j12 := uint32(k[20]) | uint32(k[21])<<8 | uint32(k[22])<<16 | uint32(k[23])<<24
|
||||||
|
j13 := uint32(k[24]) | uint32(k[25])<<8 | uint32(k[26])<<16 | uint32(k[27])<<24
|
||||||
|
j14 := uint32(k[28]) | uint32(k[29])<<8 | uint32(k[30])<<16 | uint32(k[31])<<24
|
||||||
|
j15 := uint32(c[12]) | uint32(c[13])<<8 | uint32(c[14])<<16 | uint32(c[15])<<24
|
||||||
|
|
||||||
|
x0, x1, x2, x3, x4, x5, x6, x7, x8 := j0, j1, j2, j3, j4, j5, j6, j7, j8
|
||||||
|
x9, x10, x11, x12, x13, x14, x15 := j9, j10, j11, j12, j13, j14, j15
|
||||||
|
|
||||||
|
for i := 0; i < rounds; i += 2 {
|
||||||
|
u := x0 + x12
|
||||||
|
x4 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x4 + x0
|
||||||
|
x8 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x8 + x4
|
||||||
|
x12 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x12 + x8
|
||||||
|
x0 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x5 + x1
|
||||||
|
x9 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x9 + x5
|
||||||
|
x13 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x13 + x9
|
||||||
|
x1 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x1 + x13
|
||||||
|
x5 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x10 + x6
|
||||||
|
x14 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x14 + x10
|
||||||
|
x2 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x2 + x14
|
||||||
|
x6 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x6 + x2
|
||||||
|
x10 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x15 + x11
|
||||||
|
x3 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x3 + x15
|
||||||
|
x7 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x7 + x3
|
||||||
|
x11 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x11 + x7
|
||||||
|
x15 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x0 + x3
|
||||||
|
x1 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x1 + x0
|
||||||
|
x2 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x2 + x1
|
||||||
|
x3 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x3 + x2
|
||||||
|
x0 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x5 + x4
|
||||||
|
x6 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x6 + x5
|
||||||
|
x7 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x7 + x6
|
||||||
|
x4 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x4 + x7
|
||||||
|
x5 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x10 + x9
|
||||||
|
x11 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x11 + x10
|
||||||
|
x8 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x8 + x11
|
||||||
|
x9 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x9 + x8
|
||||||
|
x10 ^= u<<18 | u>>(32-18)
|
||||||
|
|
||||||
|
u = x15 + x14
|
||||||
|
x12 ^= u<<7 | u>>(32-7)
|
||||||
|
u = x12 + x15
|
||||||
|
x13 ^= u<<9 | u>>(32-9)
|
||||||
|
u = x13 + x12
|
||||||
|
x14 ^= u<<13 | u>>(32-13)
|
||||||
|
u = x14 + x13
|
||||||
|
x15 ^= u<<18 | u>>(32-18)
|
||||||
|
}
|
||||||
|
x0 += j0
|
||||||
|
x1 += j1
|
||||||
|
x2 += j2
|
||||||
|
x3 += j3
|
||||||
|
x4 += j4
|
||||||
|
x5 += j5
|
||||||
|
x6 += j6
|
||||||
|
x7 += j7
|
||||||
|
x8 += j8
|
||||||
|
x9 += j9
|
||||||
|
x10 += j10
|
||||||
|
x11 += j11
|
||||||
|
x12 += j12
|
||||||
|
x13 += j13
|
||||||
|
x14 += j14
|
||||||
|
x15 += j15
|
||||||
|
|
||||||
|
out[0] = byte(x0)
|
||||||
|
out[1] = byte(x0 >> 8)
|
||||||
|
out[2] = byte(x0 >> 16)
|
||||||
|
out[3] = byte(x0 >> 24)
|
||||||
|
|
||||||
|
out[4] = byte(x1)
|
||||||
|
out[5] = byte(x1 >> 8)
|
||||||
|
out[6] = byte(x1 >> 16)
|
||||||
|
out[7] = byte(x1 >> 24)
|
||||||
|
|
||||||
|
out[8] = byte(x2)
|
||||||
|
out[9] = byte(x2 >> 8)
|
||||||
|
out[10] = byte(x2 >> 16)
|
||||||
|
out[11] = byte(x2 >> 24)
|
||||||
|
|
||||||
|
out[12] = byte(x3)
|
||||||
|
out[13] = byte(x3 >> 8)
|
||||||
|
out[14] = byte(x3 >> 16)
|
||||||
|
out[15] = byte(x3 >> 24)
|
||||||
|
|
||||||
|
out[16] = byte(x4)
|
||||||
|
out[17] = byte(x4 >> 8)
|
||||||
|
out[18] = byte(x4 >> 16)
|
||||||
|
out[19] = byte(x4 >> 24)
|
||||||
|
|
||||||
|
out[20] = byte(x5)
|
||||||
|
out[21] = byte(x5 >> 8)
|
||||||
|
out[22] = byte(x5 >> 16)
|
||||||
|
out[23] = byte(x5 >> 24)
|
||||||
|
|
||||||
|
out[24] = byte(x6)
|
||||||
|
out[25] = byte(x6 >> 8)
|
||||||
|
out[26] = byte(x6 >> 16)
|
||||||
|
out[27] = byte(x6 >> 24)
|
||||||
|
|
||||||
|
out[28] = byte(x7)
|
||||||
|
out[29] = byte(x7 >> 8)
|
||||||
|
out[30] = byte(x7 >> 16)
|
||||||
|
out[31] = byte(x7 >> 24)
|
||||||
|
|
||||||
|
out[32] = byte(x8)
|
||||||
|
out[33] = byte(x8 >> 8)
|
||||||
|
out[34] = byte(x8 >> 16)
|
||||||
|
out[35] = byte(x8 >> 24)
|
||||||
|
|
||||||
|
out[36] = byte(x9)
|
||||||
|
out[37] = byte(x9 >> 8)
|
||||||
|
out[38] = byte(x9 >> 16)
|
||||||
|
out[39] = byte(x9 >> 24)
|
||||||
|
|
||||||
|
out[40] = byte(x10)
|
||||||
|
out[41] = byte(x10 >> 8)
|
||||||
|
out[42] = byte(x10 >> 16)
|
||||||
|
out[43] = byte(x10 >> 24)
|
||||||
|
|
||||||
|
out[44] = byte(x11)
|
||||||
|
out[45] = byte(x11 >> 8)
|
||||||
|
out[46] = byte(x11 >> 16)
|
||||||
|
out[47] = byte(x11 >> 24)
|
||||||
|
|
||||||
|
out[48] = byte(x12)
|
||||||
|
out[49] = byte(x12 >> 8)
|
||||||
|
out[50] = byte(x12 >> 16)
|
||||||
|
out[51] = byte(x12 >> 24)
|
||||||
|
|
||||||
|
out[52] = byte(x13)
|
||||||
|
out[53] = byte(x13 >> 8)
|
||||||
|
out[54] = byte(x13 >> 16)
|
||||||
|
out[55] = byte(x13 >> 24)
|
||||||
|
|
||||||
|
out[56] = byte(x14)
|
||||||
|
out[57] = byte(x14 >> 8)
|
||||||
|
out[58] = byte(x14 >> 16)
|
||||||
|
out[59] = byte(x14 >> 24)
|
||||||
|
|
||||||
|
out[60] = byte(x15)
|
||||||
|
out[61] = byte(x15 >> 8)
|
||||||
|
out[62] = byte(x15 >> 16)
|
||||||
|
out[63] = byte(x15 >> 24)
|
||||||
|
}
|
||||||
|
|
||||||
|
// genericXORKeyStream is the generic implementation of XORKeyStream to be used
|
||||||
|
// when no assembly implementation is available.
|
||||||
|
func genericXORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
|
||||||
|
var block [64]byte
|
||||||
|
var counterCopy [16]byte
|
||||||
|
copy(counterCopy[:], counter[:])
|
||||||
|
|
||||||
|
for len(in) >= 64 {
|
||||||
|
core(&block, &counterCopy, key, &Sigma)
|
||||||
|
for i, x := range block {
|
||||||
|
out[i] = in[i] ^ x
|
||||||
|
}
|
||||||
|
u := uint32(1)
|
||||||
|
for i := 8; i < 16; i++ {
|
||||||
|
u += uint32(counterCopy[i])
|
||||||
|
counterCopy[i] = byte(u)
|
||||||
|
u >>= 8
|
||||||
|
}
|
||||||
|
in = in[64:]
|
||||||
|
out = out[64:]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(in) > 0 {
|
||||||
|
core(&block, &counterCopy, key, &Sigma)
|
||||||
|
for i, v := range in {
|
||||||
|
out[i] = v ^ block[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
vendor/golang.org/x/sys/AUTHORS
generated
vendored
Normal file
3
vendor/golang.org/x/sys/AUTHORS
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# This source code refers to The Go Authors for copyright purposes.
|
||||||
|
# The master list of authors is in the main Go distribution,
|
||||||
|
# visible at http://tip.golang.org/AUTHORS.
|
3
vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
Normal file
3
vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# This source code was written by the Go contributors.
|
||||||
|
# The master list of contributors is in the main Go distribution,
|
||||||
|
# visible at http://tip.golang.org/CONTRIBUTORS.
|
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
Normal file
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
Google as part of the Go project.
|
||||||
|
|
||||||
|
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||||
|
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||||
|
patent license to make, have made, use, offer to sell, sell, import,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation of Go, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by Google and acquired in
|
||||||
|
the future, licensable by Google that are necessarily infringed by this
|
||||||
|
implementation of Go. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation of Go or any code incorporated within this
|
||||||
|
implementation of Go constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation of Go
|
||||||
|
shall terminate as of the date such litigation is filed.
|
18
vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s
generated
vendored
Normal file
18
vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build gc
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go
|
||||||
|
//
|
||||||
|
|
||||||
|
TEXT ·syscall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·rawSyscall6(SB)
|
65
vendor/golang.org/x/sys/cpu/byteorder.go
generated
vendored
Normal file
65
vendor/golang.org/x/sys/cpu/byteorder.go
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// byteOrder is a subset of encoding/binary.ByteOrder.
|
||||||
|
type byteOrder interface {
|
||||||
|
Uint32([]byte) uint32
|
||||||
|
Uint64([]byte) uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type littleEndian struct{}
|
||||||
|
type bigEndian struct{}
|
||||||
|
|
||||||
|
func (littleEndian) Uint32(b []byte) uint32 {
|
||||||
|
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
|
||||||
|
}
|
||||||
|
|
||||||
|
func (littleEndian) Uint64(b []byte) uint64 {
|
||||||
|
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
|
||||||
|
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bigEndian) Uint32(b []byte) uint32 {
|
||||||
|
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bigEndian) Uint64(b []byte) uint64 {
|
||||||
|
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
|
||||||
|
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
||||||
|
}
|
||||||
|
|
||||||
|
// hostByteOrder returns littleEndian on little-endian machines and
|
||||||
|
// bigEndian on big-endian machines.
|
||||||
|
func hostByteOrder() byteOrder {
|
||||||
|
switch runtime.GOARCH {
|
||||||
|
case "386", "amd64", "amd64p32",
|
||||||
|
"alpha",
|
||||||
|
"arm", "arm64",
|
||||||
|
"mipsle", "mips64le", "mips64p32le",
|
||||||
|
"nios2",
|
||||||
|
"ppc64le",
|
||||||
|
"riscv", "riscv64",
|
||||||
|
"sh":
|
||||||
|
return littleEndian{}
|
||||||
|
case "armbe", "arm64be",
|
||||||
|
"m68k",
|
||||||
|
"mips", "mips64", "mips64p32",
|
||||||
|
"ppc", "ppc64",
|
||||||
|
"s390", "s390x",
|
||||||
|
"shbe",
|
||||||
|
"sparc", "sparc64":
|
||||||
|
return bigEndian{}
|
||||||
|
}
|
||||||
|
panic("unknown architecture")
|
||||||
|
}
|
287
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
Normal file
287
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
// Package cpu implements processor feature detection for
|
||||||
|
// various CPU architectures.
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Initialized reports whether the CPU features were initialized.
|
||||||
|
//
|
||||||
|
// For some GOOS/GOARCH combinations initialization of the CPU features depends
|
||||||
|
// on reading an operating specific file, e.g. /proc/self/auxv on linux/arm
|
||||||
|
// Initialized will report false if reading the file fails.
|
||||||
|
var Initialized bool
|
||||||
|
|
||||||
|
// CacheLinePad is used to pad structs to avoid false sharing.
|
||||||
|
type CacheLinePad struct{ _ [cacheLineSize]byte }
|
||||||
|
|
||||||
|
// X86 contains the supported CPU features of the
|
||||||
|
// current X86/AMD64 platform. If the current platform
|
||||||
|
// is not X86/AMD64 then all feature flags are false.
|
||||||
|
//
|
||||||
|
// X86 is padded to avoid false sharing. Further the HasAVX
|
||||||
|
// and HasAVX2 are only set if the OS supports XMM and YMM
|
||||||
|
// registers in addition to the CPUID feature bit being set.
|
||||||
|
var X86 struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasAES bool // AES hardware implementation (AES NI)
|
||||||
|
HasADX bool // Multi-precision add-carry instruction extensions
|
||||||
|
HasAVX bool // Advanced vector extension
|
||||||
|
HasAVX2 bool // Advanced vector extension 2
|
||||||
|
HasAVX512 bool // Advanced vector extension 512
|
||||||
|
HasAVX512F bool // Advanced vector extension 512 Foundation Instructions
|
||||||
|
HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions
|
||||||
|
HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions
|
||||||
|
HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions Instructions
|
||||||
|
HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions
|
||||||
|
HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions
|
||||||
|
HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions
|
||||||
|
HasAVX512IFMA bool // Advanced vector extension 512 Integer Fused Multiply Add
|
||||||
|
HasAVX512VBMI bool // Advanced vector extension 512 Vector Byte Manipulation Instructions
|
||||||
|
HasAVX5124VNNIW bool // Advanced vector extension 512 Vector Neural Network Instructions Word variable precision
|
||||||
|
HasAVX5124FMAPS bool // Advanced vector extension 512 Fused Multiply Accumulation Packed Single precision
|
||||||
|
HasAVX512VPOPCNTDQ bool // Advanced vector extension 512 Double and quad word population count instructions
|
||||||
|
HasAVX512VPCLMULQDQ bool // Advanced vector extension 512 Vector carry-less multiply operations
|
||||||
|
HasAVX512VNNI bool // Advanced vector extension 512 Vector Neural Network Instructions
|
||||||
|
HasAVX512GFNI bool // Advanced vector extension 512 Galois field New Instructions
|
||||||
|
HasAVX512VAES bool // Advanced vector extension 512 Vector AES instructions
|
||||||
|
HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2
|
||||||
|
HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms
|
||||||
|
HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions
|
||||||
|
HasBMI1 bool // Bit manipulation instruction set 1
|
||||||
|
HasBMI2 bool // Bit manipulation instruction set 2
|
||||||
|
HasCX16 bool // Compare and exchange 16 Bytes
|
||||||
|
HasERMS bool // Enhanced REP for MOVSB and STOSB
|
||||||
|
HasFMA bool // Fused-multiply-add instructions
|
||||||
|
HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
|
||||||
|
HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
|
||||||
|
HasPOPCNT bool // Hamming weight instruction POPCNT.
|
||||||
|
HasRDRAND bool // RDRAND instruction (on-chip random number generator)
|
||||||
|
HasRDSEED bool // RDSEED instruction (on-chip random number generator)
|
||||||
|
HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64)
|
||||||
|
HasSSE3 bool // Streaming SIMD extension 3
|
||||||
|
HasSSSE3 bool // Supplemental streaming SIMD extension 3
|
||||||
|
HasSSE41 bool // Streaming SIMD extension 4 and 4.1
|
||||||
|
HasSSE42 bool // Streaming SIMD extension 4 and 4.2
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
|
// ARM64 contains the supported CPU features of the
|
||||||
|
// current ARMv8(aarch64) platform. If the current platform
|
||||||
|
// is not arm64 then all feature flags are false.
|
||||||
|
var ARM64 struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasFP bool // Floating-point instruction set (always available)
|
||||||
|
HasASIMD bool // Advanced SIMD (always available)
|
||||||
|
HasEVTSTRM bool // Event stream support
|
||||||
|
HasAES bool // AES hardware implementation
|
||||||
|
HasPMULL bool // Polynomial multiplication instruction set
|
||||||
|
HasSHA1 bool // SHA1 hardware implementation
|
||||||
|
HasSHA2 bool // SHA2 hardware implementation
|
||||||
|
HasCRC32 bool // CRC32 hardware implementation
|
||||||
|
HasATOMICS bool // Atomic memory operation instruction set
|
||||||
|
HasFPHP bool // Half precision floating-point instruction set
|
||||||
|
HasASIMDHP bool // Advanced SIMD half precision instruction set
|
||||||
|
HasCPUID bool // CPUID identification scheme registers
|
||||||
|
HasASIMDRDM bool // Rounding double multiply add/subtract instruction set
|
||||||
|
HasJSCVT bool // Javascript conversion from floating-point to integer
|
||||||
|
HasFCMA bool // Floating-point multiplication and addition of complex numbers
|
||||||
|
HasLRCPC bool // Release Consistent processor consistent support
|
||||||
|
HasDCPOP bool // Persistent memory support
|
||||||
|
HasSHA3 bool // SHA3 hardware implementation
|
||||||
|
HasSM3 bool // SM3 hardware implementation
|
||||||
|
HasSM4 bool // SM4 hardware implementation
|
||||||
|
HasASIMDDP bool // Advanced SIMD double precision instruction set
|
||||||
|
HasSHA512 bool // SHA512 hardware implementation
|
||||||
|
HasSVE bool // Scalable Vector Extensions
|
||||||
|
HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
|
// ARM contains the supported CPU features of the current ARM (32-bit) platform.
|
||||||
|
// All feature flags are false if:
|
||||||
|
// 1. the current platform is not arm, or
|
||||||
|
// 2. the current operating system is not Linux.
|
||||||
|
var ARM struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasSWP bool // SWP instruction support
|
||||||
|
HasHALF bool // Half-word load and store support
|
||||||
|
HasTHUMB bool // ARM Thumb instruction set
|
||||||
|
Has26BIT bool // Address space limited to 26-bits
|
||||||
|
HasFASTMUL bool // 32-bit operand, 64-bit result multiplication support
|
||||||
|
HasFPA bool // Floating point arithmetic support
|
||||||
|
HasVFP bool // Vector floating point support
|
||||||
|
HasEDSP bool // DSP Extensions support
|
||||||
|
HasJAVA bool // Java instruction set
|
||||||
|
HasIWMMXT bool // Intel Wireless MMX technology support
|
||||||
|
HasCRUNCH bool // MaverickCrunch context switching and handling
|
||||||
|
HasTHUMBEE bool // Thumb EE instruction set
|
||||||
|
HasNEON bool // NEON instruction set
|
||||||
|
HasVFPv3 bool // Vector floating point version 3 support
|
||||||
|
HasVFPv3D16 bool // Vector floating point version 3 D8-D15
|
||||||
|
HasTLS bool // Thread local storage support
|
||||||
|
HasVFPv4 bool // Vector floating point version 4 support
|
||||||
|
HasIDIVA bool // Integer divide instruction support in ARM mode
|
||||||
|
HasIDIVT bool // Integer divide instruction support in Thumb mode
|
||||||
|
HasVFPD32 bool // Vector floating point version 3 D15-D31
|
||||||
|
HasLPAE bool // Large Physical Address Extensions
|
||||||
|
HasEVTSTRM bool // Event stream support
|
||||||
|
HasAES bool // AES hardware implementation
|
||||||
|
HasPMULL bool // Polynomial multiplication instruction set
|
||||||
|
HasSHA1 bool // SHA1 hardware implementation
|
||||||
|
HasSHA2 bool // SHA2 hardware implementation
|
||||||
|
HasCRC32 bool // CRC32 hardware implementation
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
|
// MIPS64X contains the supported CPU features of the current mips64/mips64le
|
||||||
|
// platforms. If the current platform is not mips64/mips64le or the current
|
||||||
|
// operating system is not Linux then all feature flags are false.
|
||||||
|
var MIPS64X struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasMSA bool // MIPS SIMD architecture
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
|
// PPC64 contains the supported CPU features of the current ppc64/ppc64le platforms.
|
||||||
|
// If the current platform is not ppc64/ppc64le then all feature flags are false.
|
||||||
|
//
|
||||||
|
// For ppc64/ppc64le, it is safe to check only for ISA level starting on ISA v3.00,
|
||||||
|
// since there are no optional categories. There are some exceptions that also
|
||||||
|
// require kernel support to work (DARN, SCV), so there are feature bits for
|
||||||
|
// those as well. The struct is padded to avoid false sharing.
|
||||||
|
var PPC64 struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasDARN bool // Hardware random number generator (requires kernel enablement)
|
||||||
|
HasSCV bool // Syscall vectored (requires kernel enablement)
|
||||||
|
IsPOWER8 bool // ISA v2.07 (POWER8)
|
||||||
|
IsPOWER9 bool // ISA v3.00 (POWER9), implies IsPOWER8
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
|
// S390X contains the supported CPU features of the current IBM Z
|
||||||
|
// (s390x) platform. If the current platform is not IBM Z then all
|
||||||
|
// feature flags are false.
|
||||||
|
//
|
||||||
|
// S390X is padded to avoid false sharing. Further HasVX is only set
|
||||||
|
// if the OS supports vector registers in addition to the STFLE
|
||||||
|
// feature bit being set.
|
||||||
|
var S390X struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasZARCH bool // z/Architecture mode is active [mandatory]
|
||||||
|
HasSTFLE bool // store facility list extended
|
||||||
|
HasLDISP bool // long (20-bit) displacements
|
||||||
|
HasEIMM bool // 32-bit immediates
|
||||||
|
HasDFP bool // decimal floating point
|
||||||
|
HasETF3EH bool // ETF-3 enhanced
|
||||||
|
HasMSA bool // message security assist (CPACF)
|
||||||
|
HasAES bool // KM-AES{128,192,256} functions
|
||||||
|
HasAESCBC bool // KMC-AES{128,192,256} functions
|
||||||
|
HasAESCTR bool // KMCTR-AES{128,192,256} functions
|
||||||
|
HasAESGCM bool // KMA-GCM-AES{128,192,256} functions
|
||||||
|
HasGHASH bool // KIMD-GHASH function
|
||||||
|
HasSHA1 bool // K{I,L}MD-SHA-1 functions
|
||||||
|
HasSHA256 bool // K{I,L}MD-SHA-256 functions
|
||||||
|
HasSHA512 bool // K{I,L}MD-SHA-512 functions
|
||||||
|
HasSHA3 bool // K{I,L}MD-SHA3-{224,256,384,512} and K{I,L}MD-SHAKE-{128,256} functions
|
||||||
|
HasVX bool // vector facility
|
||||||
|
HasVXE bool // vector-enhancements facility 1
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
archInit()
|
||||||
|
initOptions()
|
||||||
|
processOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
// options contains the cpu debug options that can be used in GODEBUG.
|
||||||
|
// Options are arch dependent and are added by the arch specific initOptions functions.
|
||||||
|
// Features that are mandatory for the specific GOARCH should have the Required field set
|
||||||
|
// (e.g. SSE2 on amd64).
|
||||||
|
var options []option
|
||||||
|
|
||||||
|
// Option names should be lower case. e.g. avx instead of AVX.
|
||||||
|
type option struct {
|
||||||
|
Name string
|
||||||
|
Feature *bool
|
||||||
|
Specified bool // whether feature value was specified in GODEBUG
|
||||||
|
Enable bool // whether feature should be enabled
|
||||||
|
Required bool // whether feature is mandatory and can not be disabled
|
||||||
|
}
|
||||||
|
|
||||||
|
func processOptions() {
|
||||||
|
env := os.Getenv("GODEBUG")
|
||||||
|
field:
|
||||||
|
for env != "" {
|
||||||
|
field := ""
|
||||||
|
i := strings.IndexByte(env, ',')
|
||||||
|
if i < 0 {
|
||||||
|
field, env = env, ""
|
||||||
|
} else {
|
||||||
|
field, env = env[:i], env[i+1:]
|
||||||
|
}
|
||||||
|
if len(field) < 4 || field[:4] != "cpu." {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
i = strings.IndexByte(field, '=')
|
||||||
|
if i < 0 {
|
||||||
|
print("GODEBUG sys/cpu: no value specified for \"", field, "\"\n")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
key, value := field[4:i], field[i+1:] // e.g. "SSE2", "on"
|
||||||
|
|
||||||
|
var enable bool
|
||||||
|
switch value {
|
||||||
|
case "on":
|
||||||
|
enable = true
|
||||||
|
case "off":
|
||||||
|
enable = false
|
||||||
|
default:
|
||||||
|
print("GODEBUG sys/cpu: value \"", value, "\" not supported for cpu option \"", key, "\"\n")
|
||||||
|
continue field
|
||||||
|
}
|
||||||
|
|
||||||
|
if key == "all" {
|
||||||
|
for i := range options {
|
||||||
|
options[i].Specified = true
|
||||||
|
options[i].Enable = enable || options[i].Required
|
||||||
|
}
|
||||||
|
continue field
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range options {
|
||||||
|
if options[i].Name == key {
|
||||||
|
options[i].Specified = true
|
||||||
|
options[i].Enable = enable
|
||||||
|
continue field
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print("GODEBUG sys/cpu: unknown cpu feature \"", key, "\"\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, o := range options {
|
||||||
|
if !o.Specified {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.Enable && !*o.Feature {
|
||||||
|
print("GODEBUG sys/cpu: can not enable \"", o.Name, "\", missing CPU support\n")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if !o.Enable && o.Required {
|
||||||
|
print("GODEBUG sys/cpu: can not disable \"", o.Name, "\", required CPU feature\n")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
*o.Feature = o.Enable
|
||||||
|
}
|
||||||
|
}
|
34
vendor/golang.org/x/sys/cpu/cpu_aix.go
generated
vendored
Normal file
34
vendor/golang.org/x/sys/cpu/cpu_aix.go
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build aix
|
||||||
|
// +build aix
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const (
|
||||||
|
// getsystemcfg constants
|
||||||
|
_SC_IMPL = 2
|
||||||
|
_IMPL_POWER8 = 0x10000
|
||||||
|
_IMPL_POWER9 = 0x20000
|
||||||
|
)
|
||||||
|
|
||||||
|
func archInit() {
|
||||||
|
impl := getsystemcfg(_SC_IMPL)
|
||||||
|
if impl&_IMPL_POWER8 != 0 {
|
||||||
|
PPC64.IsPOWER8 = true
|
||||||
|
}
|
||||||
|
if impl&_IMPL_POWER9 != 0 {
|
||||||
|
PPC64.IsPOWER8 = true
|
||||||
|
PPC64.IsPOWER9 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
Initialized = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func getsystemcfg(label int) (n uint64) {
|
||||||
|
r0, _ := callgetsystemcfg(label)
|
||||||
|
n = uint64(r0)
|
||||||
|
return
|
||||||
|
}
|
73
vendor/golang.org/x/sys/cpu/cpu_arm.go
generated
vendored
Normal file
73
vendor/golang.org/x/sys/cpu/cpu_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 32
|
||||||
|
|
||||||
|
// HWCAP/HWCAP2 bits.
|
||||||
|
// These are specific to Linux.
|
||||||
|
const (
|
||||||
|
hwcap_SWP = 1 << 0
|
||||||
|
hwcap_HALF = 1 << 1
|
||||||
|
hwcap_THUMB = 1 << 2
|
||||||
|
hwcap_26BIT = 1 << 3
|
||||||
|
hwcap_FAST_MULT = 1 << 4
|
||||||
|
hwcap_FPA = 1 << 5
|
||||||
|
hwcap_VFP = 1 << 6
|
||||||
|
hwcap_EDSP = 1 << 7
|
||||||
|
hwcap_JAVA = 1 << 8
|
||||||
|
hwcap_IWMMXT = 1 << 9
|
||||||
|
hwcap_CRUNCH = 1 << 10
|
||||||
|
hwcap_THUMBEE = 1 << 11
|
||||||
|
hwcap_NEON = 1 << 12
|
||||||
|
hwcap_VFPv3 = 1 << 13
|
||||||
|
hwcap_VFPv3D16 = 1 << 14
|
||||||
|
hwcap_TLS = 1 << 15
|
||||||
|
hwcap_VFPv4 = 1 << 16
|
||||||
|
hwcap_IDIVA = 1 << 17
|
||||||
|
hwcap_IDIVT = 1 << 18
|
||||||
|
hwcap_VFPD32 = 1 << 19
|
||||||
|
hwcap_LPAE = 1 << 20
|
||||||
|
hwcap_EVTSTRM = 1 << 21
|
||||||
|
|
||||||
|
hwcap2_AES = 1 << 0
|
||||||
|
hwcap2_PMULL = 1 << 1
|
||||||
|
hwcap2_SHA1 = 1 << 2
|
||||||
|
hwcap2_SHA2 = 1 << 3
|
||||||
|
hwcap2_CRC32 = 1 << 4
|
||||||
|
)
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "pmull", Feature: &ARM.HasPMULL},
|
||||||
|
{Name: "sha1", Feature: &ARM.HasSHA1},
|
||||||
|
{Name: "sha2", Feature: &ARM.HasSHA2},
|
||||||
|
{Name: "swp", Feature: &ARM.HasSWP},
|
||||||
|
{Name: "thumb", Feature: &ARM.HasTHUMB},
|
||||||
|
{Name: "thumbee", Feature: &ARM.HasTHUMBEE},
|
||||||
|
{Name: "tls", Feature: &ARM.HasTLS},
|
||||||
|
{Name: "vfp", Feature: &ARM.HasVFP},
|
||||||
|
{Name: "vfpd32", Feature: &ARM.HasVFPD32},
|
||||||
|
{Name: "vfpv3", Feature: &ARM.HasVFPv3},
|
||||||
|
{Name: "vfpv3d16", Feature: &ARM.HasVFPv3D16},
|
||||||
|
{Name: "vfpv4", Feature: &ARM.HasVFPv4},
|
||||||
|
{Name: "half", Feature: &ARM.HasHALF},
|
||||||
|
{Name: "26bit", Feature: &ARM.Has26BIT},
|
||||||
|
{Name: "fastmul", Feature: &ARM.HasFASTMUL},
|
||||||
|
{Name: "fpa", Feature: &ARM.HasFPA},
|
||||||
|
{Name: "edsp", Feature: &ARM.HasEDSP},
|
||||||
|
{Name: "java", Feature: &ARM.HasJAVA},
|
||||||
|
{Name: "iwmmxt", Feature: &ARM.HasIWMMXT},
|
||||||
|
{Name: "crunch", Feature: &ARM.HasCRUNCH},
|
||||||
|
{Name: "neon", Feature: &ARM.HasNEON},
|
||||||
|
{Name: "idivt", Feature: &ARM.HasIDIVT},
|
||||||
|
{Name: "idiva", Feature: &ARM.HasIDIVA},
|
||||||
|
{Name: "lpae", Feature: &ARM.HasLPAE},
|
||||||
|
{Name: "evtstrm", Feature: &ARM.HasEVTSTRM},
|
||||||
|
{Name: "aes", Feature: &ARM.HasAES},
|
||||||
|
{Name: "crc32", Feature: &ARM.HasCRC32},
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
172
vendor/golang.org/x/sys/cpu/cpu_arm64.go
generated
vendored
Normal file
172
vendor/golang.org/x/sys/cpu/cpu_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
const cacheLineSize = 64
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "fp", Feature: &ARM64.HasFP},
|
||||||
|
{Name: "asimd", Feature: &ARM64.HasASIMD},
|
||||||
|
{Name: "evstrm", Feature: &ARM64.HasEVTSTRM},
|
||||||
|
{Name: "aes", Feature: &ARM64.HasAES},
|
||||||
|
{Name: "fphp", Feature: &ARM64.HasFPHP},
|
||||||
|
{Name: "jscvt", Feature: &ARM64.HasJSCVT},
|
||||||
|
{Name: "lrcpc", Feature: &ARM64.HasLRCPC},
|
||||||
|
{Name: "pmull", Feature: &ARM64.HasPMULL},
|
||||||
|
{Name: "sha1", Feature: &ARM64.HasSHA1},
|
||||||
|
{Name: "sha2", Feature: &ARM64.HasSHA2},
|
||||||
|
{Name: "sha3", Feature: &ARM64.HasSHA3},
|
||||||
|
{Name: "sha512", Feature: &ARM64.HasSHA512},
|
||||||
|
{Name: "sm3", Feature: &ARM64.HasSM3},
|
||||||
|
{Name: "sm4", Feature: &ARM64.HasSM4},
|
||||||
|
{Name: "sve", Feature: &ARM64.HasSVE},
|
||||||
|
{Name: "crc32", Feature: &ARM64.HasCRC32},
|
||||||
|
{Name: "atomics", Feature: &ARM64.HasATOMICS},
|
||||||
|
{Name: "asimdhp", Feature: &ARM64.HasASIMDHP},
|
||||||
|
{Name: "cpuid", Feature: &ARM64.HasCPUID},
|
||||||
|
{Name: "asimrdm", Feature: &ARM64.HasASIMDRDM},
|
||||||
|
{Name: "fcma", Feature: &ARM64.HasFCMA},
|
||||||
|
{Name: "dcpop", Feature: &ARM64.HasDCPOP},
|
||||||
|
{Name: "asimddp", Feature: &ARM64.HasASIMDDP},
|
||||||
|
{Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func archInit() {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "freebsd":
|
||||||
|
readARM64Registers()
|
||||||
|
case "linux", "netbsd":
|
||||||
|
doinit()
|
||||||
|
default:
|
||||||
|
// Most platforms don't seem to allow reading these registers.
|
||||||
|
//
|
||||||
|
// OpenBSD:
|
||||||
|
// See https://golang.org/issue/31746
|
||||||
|
setMinimalFeatures()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// setMinimalFeatures fakes the minimal ARM64 features expected by
|
||||||
|
// TestARM64minimalFeatures.
|
||||||
|
func setMinimalFeatures() {
|
||||||
|
ARM64.HasASIMD = true
|
||||||
|
ARM64.HasFP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func readARM64Registers() {
|
||||||
|
Initialized = true
|
||||||
|
|
||||||
|
parseARM64SystemRegisters(getisar0(), getisar1(), getpfr0())
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) {
|
||||||
|
// ID_AA64ISAR0_EL1
|
||||||
|
switch extractBits(isar0, 4, 7) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasAES = true
|
||||||
|
case 2:
|
||||||
|
ARM64.HasAES = true
|
||||||
|
ARM64.HasPMULL = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 8, 11) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSHA1 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 12, 15) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSHA2 = true
|
||||||
|
case 2:
|
||||||
|
ARM64.HasSHA2 = true
|
||||||
|
ARM64.HasSHA512 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 16, 19) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasCRC32 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 20, 23) {
|
||||||
|
case 2:
|
||||||
|
ARM64.HasATOMICS = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 28, 31) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasASIMDRDM = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 32, 35) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSHA3 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 36, 39) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSM3 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 40, 43) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSM4 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar0, 44, 47) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasASIMDDP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID_AA64ISAR1_EL1
|
||||||
|
switch extractBits(isar1, 0, 3) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasDCPOP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar1, 12, 15) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasJSCVT = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar1, 16, 19) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasFCMA = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(isar1, 20, 23) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasLRCPC = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID_AA64PFR0_EL1
|
||||||
|
switch extractBits(pfr0, 16, 19) {
|
||||||
|
case 0:
|
||||||
|
ARM64.HasFP = true
|
||||||
|
case 1:
|
||||||
|
ARM64.HasFP = true
|
||||||
|
ARM64.HasFPHP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(pfr0, 20, 23) {
|
||||||
|
case 0:
|
||||||
|
ARM64.HasASIMD = true
|
||||||
|
case 1:
|
||||||
|
ARM64.HasASIMD = true
|
||||||
|
ARM64.HasASIMDHP = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch extractBits(pfr0, 32, 35) {
|
||||||
|
case 1:
|
||||||
|
ARM64.HasSVE = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractBits(data uint64, start, end uint) uint {
|
||||||
|
return (uint)(data>>start) & ((1 << (end - start + 1)) - 1)
|
||||||
|
}
|
32
vendor/golang.org/x/sys/cpu/cpu_arm64.s
generated
vendored
Normal file
32
vendor/golang.org/x/sys/cpu/cpu_arm64.s
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gc
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func getisar0() uint64
|
||||||
|
TEXT ·getisar0(SB),NOSPLIT,$0-8
|
||||||
|
// get Instruction Set Attributes 0 into x0
|
||||||
|
// mrs x0, ID_AA64ISAR0_EL1 = d5380600
|
||||||
|
WORD $0xd5380600
|
||||||
|
MOVD R0, ret+0(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func getisar1() uint64
|
||||||
|
TEXT ·getisar1(SB),NOSPLIT,$0-8
|
||||||
|
// get Instruction Set Attributes 1 into x0
|
||||||
|
// mrs x0, ID_AA64ISAR1_EL1 = d5380620
|
||||||
|
WORD $0xd5380620
|
||||||
|
MOVD R0, ret+0(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func getpfr0() uint64
|
||||||
|
TEXT ·getpfr0(SB),NOSPLIT,$0-8
|
||||||
|
// get Processor Feature Register 0 into x0
|
||||||
|
// mrs x0, ID_AA64PFR0_EL1 = d5380400
|
||||||
|
WORD $0xd5380400
|
||||||
|
MOVD R0, ret+0(FP)
|
||||||
|
RET
|
12
vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go
generated
vendored
Normal file
12
vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gc
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func getisar0() uint64
|
||||||
|
func getisar1() uint64
|
||||||
|
func getpfr0() uint64
|
22
vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go
generated
vendored
Normal file
22
vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gc
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// haveAsmFunctions reports whether the other functions in this file can
|
||||||
|
// be safely called.
|
||||||
|
func haveAsmFunctions() bool { return true }
|
||||||
|
|
||||||
|
// The following feature detection functions are defined in cpu_s390x.s.
|
||||||
|
// They are likely to be expensive to call so the results should be cached.
|
||||||
|
func stfle() facilityList
|
||||||
|
func kmQuery() queryResult
|
||||||
|
func kmcQuery() queryResult
|
||||||
|
func kmctrQuery() queryResult
|
||||||
|
func kmaQuery() queryResult
|
||||||
|
func kimdQuery() queryResult
|
||||||
|
func klmdQuery() queryResult
|
17
vendor/golang.org/x/sys/cpu/cpu_gc_x86.go
generated
vendored
Normal file
17
vendor/golang.org/x/sys/cpu/cpu_gc_x86.go
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build (386 || amd64 || amd64p32) && gc
|
||||||
|
// +build 386 amd64 amd64p32
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// cpuid is implemented in cpu_x86.s for gc compiler
|
||||||
|
// and in cpu_gccgo.c for gccgo.
|
||||||
|
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
|
||||||
|
|
||||||
|
// xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler
|
||||||
|
// and in cpu_gccgo.c for gccgo.
|
||||||
|
func xgetbv() (eax, edx uint32)
|
12
vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go
generated
vendored
Normal file
12
vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gccgo
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func getisar0() uint64 { return 0 }
|
||||||
|
func getisar1() uint64 { return 0 }
|
||||||
|
func getpfr0() uint64 { return 0 }
|
23
vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go
generated
vendored
Normal file
23
vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gccgo
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// haveAsmFunctions reports whether the other functions in this file can
|
||||||
|
// be safely called.
|
||||||
|
func haveAsmFunctions() bool { return false }
|
||||||
|
|
||||||
|
// TODO(mundaym): the following feature detection functions are currently
|
||||||
|
// stubs. See https://golang.org/cl/162887 for how to fix this.
|
||||||
|
// They are likely to be expensive to call so the results should be cached.
|
||||||
|
func stfle() facilityList { panic("not implemented for gccgo") }
|
||||||
|
func kmQuery() queryResult { panic("not implemented for gccgo") }
|
||||||
|
func kmcQuery() queryResult { panic("not implemented for gccgo") }
|
||||||
|
func kmctrQuery() queryResult { panic("not implemented for gccgo") }
|
||||||
|
func kmaQuery() queryResult { panic("not implemented for gccgo") }
|
||||||
|
func kimdQuery() queryResult { panic("not implemented for gccgo") }
|
||||||
|
func klmdQuery() queryResult { panic("not implemented for gccgo") }
|
43
vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c
generated
vendored
Normal file
43
vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
// +build 386 amd64 amd64p32
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
#include <cpuid.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Need to wrap __get_cpuid_count because it's declared as static.
|
||||||
|
int
|
||||||
|
gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf,
|
||||||
|
uint32_t *eax, uint32_t *ebx,
|
||||||
|
uint32_t *ecx, uint32_t *edx)
|
||||||
|
{
|
||||||
|
return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// xgetbv reads the contents of an XCR (Extended Control Register)
|
||||||
|
// specified in the ECX register into registers EDX:EAX.
|
||||||
|
// Currently, the only supported value for XCR is 0.
|
||||||
|
//
|
||||||
|
// TODO: Replace with a better alternative:
|
||||||
|
//
|
||||||
|
// #include <xsaveintrin.h>
|
||||||
|
//
|
||||||
|
// #pragma GCC target("xsave")
|
||||||
|
//
|
||||||
|
// void gccgoXgetbv(uint32_t *eax, uint32_t *edx) {
|
||||||
|
// unsigned long long x = _xgetbv(0);
|
||||||
|
// *eax = x & 0xffffffff;
|
||||||
|
// *edx = (x >> 32) & 0xffffffff;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Note that _xgetbv is defined starting with GCC 8.
|
||||||
|
void
|
||||||
|
gccgoXgetbv(uint32_t *eax, uint32_t *edx)
|
||||||
|
{
|
||||||
|
__asm(" xorl %%ecx, %%ecx\n"
|
||||||
|
" xgetbv"
|
||||||
|
: "=a"(*eax), "=d"(*edx));
|
||||||
|
}
|
33
vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go
generated
vendored
Normal file
33
vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build (386 || amd64 || amd64p32) && gccgo
|
||||||
|
// +build 386 amd64 amd64p32
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
//extern gccgoGetCpuidCount
|
||||||
|
func gccgoGetCpuidCount(eaxArg, ecxArg uint32, eax, ebx, ecx, edx *uint32)
|
||||||
|
|
||||||
|
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) {
|
||||||
|
var a, b, c, d uint32
|
||||||
|
gccgoGetCpuidCount(eaxArg, ecxArg, &a, &b, &c, &d)
|
||||||
|
return a, b, c, d
|
||||||
|
}
|
||||||
|
|
||||||
|
//extern gccgoXgetbv
|
||||||
|
func gccgoXgetbv(eax, edx *uint32)
|
||||||
|
|
||||||
|
func xgetbv() (eax, edx uint32) {
|
||||||
|
var a, d uint32
|
||||||
|
gccgoXgetbv(&a, &d)
|
||||||
|
return a, d
|
||||||
|
}
|
||||||
|
|
||||||
|
// gccgo doesn't build on Darwin, per:
|
||||||
|
// https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gcc.rb#L76
|
||||||
|
func darwinSupportsAVX512() bool {
|
||||||
|
return false
|
||||||
|
}
|
16
vendor/golang.org/x/sys/cpu/cpu_linux.go
generated
vendored
Normal file
16
vendor/golang.org/x/sys/cpu/cpu_linux.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build !386 && !amd64 && !amd64p32 && !arm64
|
||||||
|
// +build !386,!amd64,!amd64p32,!arm64
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func archInit() {
|
||||||
|
if err := readHWCAP(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
doinit()
|
||||||
|
Initialized = true
|
||||||
|
}
|
39
vendor/golang.org/x/sys/cpu/cpu_linux_arm.go
generated
vendored
Normal file
39
vendor/golang.org/x/sys/cpu/cpu_linux_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
ARM.HasSWP = isSet(hwCap, hwcap_SWP)
|
||||||
|
ARM.HasHALF = isSet(hwCap, hwcap_HALF)
|
||||||
|
ARM.HasTHUMB = isSet(hwCap, hwcap_THUMB)
|
||||||
|
ARM.Has26BIT = isSet(hwCap, hwcap_26BIT)
|
||||||
|
ARM.HasFASTMUL = isSet(hwCap, hwcap_FAST_MULT)
|
||||||
|
ARM.HasFPA = isSet(hwCap, hwcap_FPA)
|
||||||
|
ARM.HasVFP = isSet(hwCap, hwcap_VFP)
|
||||||
|
ARM.HasEDSP = isSet(hwCap, hwcap_EDSP)
|
||||||
|
ARM.HasJAVA = isSet(hwCap, hwcap_JAVA)
|
||||||
|
ARM.HasIWMMXT = isSet(hwCap, hwcap_IWMMXT)
|
||||||
|
ARM.HasCRUNCH = isSet(hwCap, hwcap_CRUNCH)
|
||||||
|
ARM.HasTHUMBEE = isSet(hwCap, hwcap_THUMBEE)
|
||||||
|
ARM.HasNEON = isSet(hwCap, hwcap_NEON)
|
||||||
|
ARM.HasVFPv3 = isSet(hwCap, hwcap_VFPv3)
|
||||||
|
ARM.HasVFPv3D16 = isSet(hwCap, hwcap_VFPv3D16)
|
||||||
|
ARM.HasTLS = isSet(hwCap, hwcap_TLS)
|
||||||
|
ARM.HasVFPv4 = isSet(hwCap, hwcap_VFPv4)
|
||||||
|
ARM.HasIDIVA = isSet(hwCap, hwcap_IDIVA)
|
||||||
|
ARM.HasIDIVT = isSet(hwCap, hwcap_IDIVT)
|
||||||
|
ARM.HasVFPD32 = isSet(hwCap, hwcap_VFPD32)
|
||||||
|
ARM.HasLPAE = isSet(hwCap, hwcap_LPAE)
|
||||||
|
ARM.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM)
|
||||||
|
ARM.HasAES = isSet(hwCap2, hwcap2_AES)
|
||||||
|
ARM.HasPMULL = isSet(hwCap2, hwcap2_PMULL)
|
||||||
|
ARM.HasSHA1 = isSet(hwCap2, hwcap2_SHA1)
|
||||||
|
ARM.HasSHA2 = isSet(hwCap2, hwcap2_SHA2)
|
||||||
|
ARM.HasCRC32 = isSet(hwCap2, hwcap2_CRC32)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
71
vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go
generated
vendored
Normal file
71
vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// HWCAP/HWCAP2 bits. These are exposed by Linux.
|
||||||
|
const (
|
||||||
|
hwcap_FP = 1 << 0
|
||||||
|
hwcap_ASIMD = 1 << 1
|
||||||
|
hwcap_EVTSTRM = 1 << 2
|
||||||
|
hwcap_AES = 1 << 3
|
||||||
|
hwcap_PMULL = 1 << 4
|
||||||
|
hwcap_SHA1 = 1 << 5
|
||||||
|
hwcap_SHA2 = 1 << 6
|
||||||
|
hwcap_CRC32 = 1 << 7
|
||||||
|
hwcap_ATOMICS = 1 << 8
|
||||||
|
hwcap_FPHP = 1 << 9
|
||||||
|
hwcap_ASIMDHP = 1 << 10
|
||||||
|
hwcap_CPUID = 1 << 11
|
||||||
|
hwcap_ASIMDRDM = 1 << 12
|
||||||
|
hwcap_JSCVT = 1 << 13
|
||||||
|
hwcap_FCMA = 1 << 14
|
||||||
|
hwcap_LRCPC = 1 << 15
|
||||||
|
hwcap_DCPOP = 1 << 16
|
||||||
|
hwcap_SHA3 = 1 << 17
|
||||||
|
hwcap_SM3 = 1 << 18
|
||||||
|
hwcap_SM4 = 1 << 19
|
||||||
|
hwcap_ASIMDDP = 1 << 20
|
||||||
|
hwcap_SHA512 = 1 << 21
|
||||||
|
hwcap_SVE = 1 << 22
|
||||||
|
hwcap_ASIMDFHM = 1 << 23
|
||||||
|
)
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
if err := readHWCAP(); err != nil {
|
||||||
|
// failed to read /proc/self/auxv, try reading registers directly
|
||||||
|
readARM64Registers()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// HWCAP feature bits
|
||||||
|
ARM64.HasFP = isSet(hwCap, hwcap_FP)
|
||||||
|
ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD)
|
||||||
|
ARM64.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM)
|
||||||
|
ARM64.HasAES = isSet(hwCap, hwcap_AES)
|
||||||
|
ARM64.HasPMULL = isSet(hwCap, hwcap_PMULL)
|
||||||
|
ARM64.HasSHA1 = isSet(hwCap, hwcap_SHA1)
|
||||||
|
ARM64.HasSHA2 = isSet(hwCap, hwcap_SHA2)
|
||||||
|
ARM64.HasCRC32 = isSet(hwCap, hwcap_CRC32)
|
||||||
|
ARM64.HasATOMICS = isSet(hwCap, hwcap_ATOMICS)
|
||||||
|
ARM64.HasFPHP = isSet(hwCap, hwcap_FPHP)
|
||||||
|
ARM64.HasASIMDHP = isSet(hwCap, hwcap_ASIMDHP)
|
||||||
|
ARM64.HasCPUID = isSet(hwCap, hwcap_CPUID)
|
||||||
|
ARM64.HasASIMDRDM = isSet(hwCap, hwcap_ASIMDRDM)
|
||||||
|
ARM64.HasJSCVT = isSet(hwCap, hwcap_JSCVT)
|
||||||
|
ARM64.HasFCMA = isSet(hwCap, hwcap_FCMA)
|
||||||
|
ARM64.HasLRCPC = isSet(hwCap, hwcap_LRCPC)
|
||||||
|
ARM64.HasDCPOP = isSet(hwCap, hwcap_DCPOP)
|
||||||
|
ARM64.HasSHA3 = isSet(hwCap, hwcap_SHA3)
|
||||||
|
ARM64.HasSM3 = isSet(hwCap, hwcap_SM3)
|
||||||
|
ARM64.HasSM4 = isSet(hwCap, hwcap_SM4)
|
||||||
|
ARM64.HasASIMDDP = isSet(hwCap, hwcap_ASIMDDP)
|
||||||
|
ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512)
|
||||||
|
ARM64.HasSVE = isSet(hwCap, hwcap_SVE)
|
||||||
|
ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
24
vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go
generated
vendored
Normal file
24
vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
//go:build linux && (mips64 || mips64le)
|
||||||
|
// +build linux
|
||||||
|
// +build mips64 mips64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// HWCAP bits. These are exposed by the Linux kernel 5.4.
|
||||||
|
const (
|
||||||
|
// CPU features
|
||||||
|
hwcap_MIPS_MSA = 1 << 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
// HWCAP feature bits
|
||||||
|
MIPS64X.HasMSA = isSet(hwCap, hwcap_MIPS_MSA)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
10
vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go
generated
vendored
Normal file
10
vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x
|
||||||
|
// +build linux,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!s390x
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func doinit() {}
|
32
vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go
generated
vendored
Normal file
32
vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build linux && (ppc64 || ppc64le)
|
||||||
|
// +build linux
|
||||||
|
// +build ppc64 ppc64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// HWCAP/HWCAP2 bits. These are exposed by the kernel.
|
||||||
|
const (
|
||||||
|
// ISA Level
|
||||||
|
_PPC_FEATURE2_ARCH_2_07 = 0x80000000
|
||||||
|
_PPC_FEATURE2_ARCH_3_00 = 0x00800000
|
||||||
|
|
||||||
|
// CPU features
|
||||||
|
_PPC_FEATURE2_DARN = 0x00200000
|
||||||
|
_PPC_FEATURE2_SCV = 0x00100000
|
||||||
|
)
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
// HWCAP2 feature bits
|
||||||
|
PPC64.IsPOWER8 = isSet(hwCap2, _PPC_FEATURE2_ARCH_2_07)
|
||||||
|
PPC64.IsPOWER9 = isSet(hwCap2, _PPC_FEATURE2_ARCH_3_00)
|
||||||
|
PPC64.HasDARN = isSet(hwCap2, _PPC_FEATURE2_DARN)
|
||||||
|
PPC64.HasSCV = isSet(hwCap2, _PPC_FEATURE2_SCV)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
40
vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go
generated
vendored
Normal file
40
vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const (
|
||||||
|
// bit mask values from /usr/include/bits/hwcap.h
|
||||||
|
hwcap_ZARCH = 2
|
||||||
|
hwcap_STFLE = 4
|
||||||
|
hwcap_MSA = 8
|
||||||
|
hwcap_LDISP = 16
|
||||||
|
hwcap_EIMM = 32
|
||||||
|
hwcap_DFP = 64
|
||||||
|
hwcap_ETF3EH = 256
|
||||||
|
hwcap_VX = 2048
|
||||||
|
hwcap_VXE = 8192
|
||||||
|
)
|
||||||
|
|
||||||
|
func initS390Xbase() {
|
||||||
|
// test HWCAP bit vector
|
||||||
|
has := func(featureMask uint) bool {
|
||||||
|
return hwCap&featureMask == featureMask
|
||||||
|
}
|
||||||
|
|
||||||
|
// mandatory
|
||||||
|
S390X.HasZARCH = has(hwcap_ZARCH)
|
||||||
|
|
||||||
|
// optional
|
||||||
|
S390X.HasSTFLE = has(hwcap_STFLE)
|
||||||
|
S390X.HasLDISP = has(hwcap_LDISP)
|
||||||
|
S390X.HasEIMM = has(hwcap_EIMM)
|
||||||
|
S390X.HasETF3EH = has(hwcap_ETF3EH)
|
||||||
|
S390X.HasDFP = has(hwcap_DFP)
|
||||||
|
S390X.HasMSA = has(hwcap_MSA)
|
||||||
|
S390X.HasVX = has(hwcap_VX)
|
||||||
|
if S390X.HasVX {
|
||||||
|
S390X.HasVXE = has(hwcap_VXE)
|
||||||
|
}
|
||||||
|
}
|
16
vendor/golang.org/x/sys/cpu/cpu_mips64x.go
generated
vendored
Normal file
16
vendor/golang.org/x/sys/cpu/cpu_mips64x.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build mips64 || mips64le
|
||||||
|
// +build mips64 mips64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 32
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "msa", Feature: &MIPS64X.HasMSA},
|
||||||
|
}
|
||||||
|
}
|
12
vendor/golang.org/x/sys/cpu/cpu_mipsx.go
generated
vendored
Normal file
12
vendor/golang.org/x/sys/cpu/cpu_mipsx.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build mips || mipsle
|
||||||
|
// +build mips mipsle
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 32
|
||||||
|
|
||||||
|
func initOptions() {}
|
173
vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go
generated
vendored
Normal file
173
vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Minimal copy of functionality from x/sys/unix so the cpu package can call
|
||||||
|
// sysctl without depending on x/sys/unix.
|
||||||
|
|
||||||
|
const (
|
||||||
|
_CTL_QUERY = -2
|
||||||
|
|
||||||
|
_SYSCTL_VERS_1 = 0x1000000
|
||||||
|
)
|
||||||
|
|
||||||
|
var _zero uintptr
|
||||||
|
|
||||||
|
func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(mib) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&mib[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
_, _, errno := syscall.Syscall6(
|
||||||
|
syscall.SYS___SYSCTL,
|
||||||
|
uintptr(_p0),
|
||||||
|
uintptr(len(mib)),
|
||||||
|
uintptr(unsafe.Pointer(old)),
|
||||||
|
uintptr(unsafe.Pointer(oldlen)),
|
||||||
|
uintptr(unsafe.Pointer(new)),
|
||||||
|
uintptr(newlen))
|
||||||
|
if errno != 0 {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type sysctlNode struct {
|
||||||
|
Flags uint32
|
||||||
|
Num int32
|
||||||
|
Name [32]int8
|
||||||
|
Ver uint32
|
||||||
|
__rsvd uint32
|
||||||
|
Un [16]byte
|
||||||
|
_sysctl_size [8]byte
|
||||||
|
_sysctl_func [8]byte
|
||||||
|
_sysctl_parent [8]byte
|
||||||
|
_sysctl_desc [8]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func sysctlNodes(mib []int32) ([]sysctlNode, error) {
|
||||||
|
var olen uintptr
|
||||||
|
|
||||||
|
// Get a list of all sysctl nodes below the given MIB by performing
|
||||||
|
// a sysctl for the given MIB with CTL_QUERY appended.
|
||||||
|
mib = append(mib, _CTL_QUERY)
|
||||||
|
qnode := sysctlNode{Flags: _SYSCTL_VERS_1}
|
||||||
|
qp := (*byte)(unsafe.Pointer(&qnode))
|
||||||
|
sz := unsafe.Sizeof(qnode)
|
||||||
|
if err := sysctl(mib, nil, &olen, qp, sz); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we know the size, get the actual nodes.
|
||||||
|
nodes := make([]sysctlNode, olen/sz)
|
||||||
|
np := (*byte)(unsafe.Pointer(&nodes[0]))
|
||||||
|
if err := sysctl(mib, np, &olen, qp, sz); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func nametomib(name string) ([]int32, error) {
|
||||||
|
// Split name into components.
|
||||||
|
var parts []string
|
||||||
|
last := 0
|
||||||
|
for i := 0; i < len(name); i++ {
|
||||||
|
if name[i] == '.' {
|
||||||
|
parts = append(parts, name[last:i])
|
||||||
|
last = i + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts = append(parts, name[last:])
|
||||||
|
|
||||||
|
mib := []int32{}
|
||||||
|
// Discover the nodes and construct the MIB OID.
|
||||||
|
for partno, part := range parts {
|
||||||
|
nodes, err := sysctlNodes(mib)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, node := range nodes {
|
||||||
|
n := make([]byte, 0)
|
||||||
|
for i := range node.Name {
|
||||||
|
if node.Name[i] != 0 {
|
||||||
|
n = append(n, byte(node.Name[i]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if string(n) == part {
|
||||||
|
mib = append(mib, int32(node.Num))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(mib) != partno+1 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mib, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// aarch64SysctlCPUID is struct aarch64_sysctl_cpu_id from NetBSD's <aarch64/armreg.h>
|
||||||
|
type aarch64SysctlCPUID struct {
|
||||||
|
midr uint64 /* Main ID Register */
|
||||||
|
revidr uint64 /* Revision ID Register */
|
||||||
|
mpidr uint64 /* Multiprocessor Affinity Register */
|
||||||
|
aa64dfr0 uint64 /* A64 Debug Feature Register 0 */
|
||||||
|
aa64dfr1 uint64 /* A64 Debug Feature Register 1 */
|
||||||
|
aa64isar0 uint64 /* A64 Instruction Set Attribute Register 0 */
|
||||||
|
aa64isar1 uint64 /* A64 Instruction Set Attribute Register 1 */
|
||||||
|
aa64mmfr0 uint64 /* A64 Memory Model Feature Register 0 */
|
||||||
|
aa64mmfr1 uint64 /* A64 Memory Model Feature Register 1 */
|
||||||
|
aa64mmfr2 uint64 /* A64 Memory Model Feature Register 2 */
|
||||||
|
aa64pfr0 uint64 /* A64 Processor Feature Register 0 */
|
||||||
|
aa64pfr1 uint64 /* A64 Processor Feature Register 1 */
|
||||||
|
aa64zfr0 uint64 /* A64 SVE Feature ID Register 0 */
|
||||||
|
mvfr0 uint32 /* Media and VFP Feature Register 0 */
|
||||||
|
mvfr1 uint32 /* Media and VFP Feature Register 1 */
|
||||||
|
mvfr2 uint32 /* Media and VFP Feature Register 2 */
|
||||||
|
pad uint32
|
||||||
|
clidr uint64 /* Cache Level ID Register */
|
||||||
|
ctr uint64 /* Cache Type Register */
|
||||||
|
}
|
||||||
|
|
||||||
|
func sysctlCPUID(name string) (*aarch64SysctlCPUID, error) {
|
||||||
|
mib, err := nametomib(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := aarch64SysctlCPUID{}
|
||||||
|
n := unsafe.Sizeof(out)
|
||||||
|
_, _, errno := syscall.Syscall6(
|
||||||
|
syscall.SYS___SYSCTL,
|
||||||
|
uintptr(unsafe.Pointer(&mib[0])),
|
||||||
|
uintptr(len(mib)),
|
||||||
|
uintptr(unsafe.Pointer(&out)),
|
||||||
|
uintptr(unsafe.Pointer(&n)),
|
||||||
|
uintptr(0),
|
||||||
|
uintptr(0))
|
||||||
|
if errno != 0 {
|
||||||
|
return nil, errno
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
cpuid, err := sysctlCPUID("machdep.cpu0.cpu_id")
|
||||||
|
if err != nil {
|
||||||
|
setMinimalFeatures()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64pfr0)
|
||||||
|
|
||||||
|
Initialized = true
|
||||||
|
}
|
10
vendor/golang.org/x/sys/cpu/cpu_other_arm.go
generated
vendored
Normal file
10
vendor/golang.org/x/sys/cpu/cpu_other_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
//go:build !linux && arm
|
||||||
|
// +build !linux,arm
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func archInit() {}
|
10
vendor/golang.org/x/sys/cpu/cpu_other_arm64.go
generated
vendored
Normal file
10
vendor/golang.org/x/sys/cpu/cpu_other_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build !linux && !netbsd && arm64
|
||||||
|
// +build !linux,!netbsd,arm64
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func doinit() {}
|
13
vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
//go:build !linux && (mips64 || mips64le)
|
||||||
|
// +build !linux
|
||||||
|
// +build mips64 mips64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func archInit() {
|
||||||
|
Initialized = true
|
||||||
|
}
|
17
vendor/golang.org/x/sys/cpu/cpu_ppc64x.go
generated
vendored
Normal file
17
vendor/golang.org/x/sys/cpu/cpu_ppc64x.go
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
//go:build ppc64 || ppc64le
|
||||||
|
// +build ppc64 ppc64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 128
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "darn", Feature: &PPC64.HasDARN},
|
||||||
|
{Name: "scv", Feature: &PPC64.HasSCV},
|
||||||
|
}
|
||||||
|
}
|
12
vendor/golang.org/x/sys/cpu/cpu_riscv64.go
generated
vendored
Normal file
12
vendor/golang.org/x/sys/cpu/cpu_riscv64.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build riscv64
|
||||||
|
// +build riscv64
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 32
|
||||||
|
|
||||||
|
func initOptions() {}
|
172
vendor/golang.org/x/sys/cpu/cpu_s390x.go
generated
vendored
Normal file
172
vendor/golang.org/x/sys/cpu/cpu_s390x.go
generated
vendored
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 256
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "zarch", Feature: &S390X.HasZARCH, Required: true},
|
||||||
|
{Name: "stfle", Feature: &S390X.HasSTFLE, Required: true},
|
||||||
|
{Name: "ldisp", Feature: &S390X.HasLDISP, Required: true},
|
||||||
|
{Name: "eimm", Feature: &S390X.HasEIMM, Required: true},
|
||||||
|
{Name: "dfp", Feature: &S390X.HasDFP},
|
||||||
|
{Name: "etf3eh", Feature: &S390X.HasETF3EH},
|
||||||
|
{Name: "msa", Feature: &S390X.HasMSA},
|
||||||
|
{Name: "aes", Feature: &S390X.HasAES},
|
||||||
|
{Name: "aescbc", Feature: &S390X.HasAESCBC},
|
||||||
|
{Name: "aesctr", Feature: &S390X.HasAESCTR},
|
||||||
|
{Name: "aesgcm", Feature: &S390X.HasAESGCM},
|
||||||
|
{Name: "ghash", Feature: &S390X.HasGHASH},
|
||||||
|
{Name: "sha1", Feature: &S390X.HasSHA1},
|
||||||
|
{Name: "sha256", Feature: &S390X.HasSHA256},
|
||||||
|
{Name: "sha3", Feature: &S390X.HasSHA3},
|
||||||
|
{Name: "sha512", Feature: &S390X.HasSHA512},
|
||||||
|
{Name: "vx", Feature: &S390X.HasVX},
|
||||||
|
{Name: "vxe", Feature: &S390X.HasVXE},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bitIsSet reports whether the bit at index is set. The bit index
|
||||||
|
// is in big endian order, so bit index 0 is the leftmost bit.
|
||||||
|
func bitIsSet(bits []uint64, index uint) bool {
|
||||||
|
return bits[index/64]&((1<<63)>>(index%64)) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// facility is a bit index for the named facility.
|
||||||
|
type facility uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// mandatory facilities
|
||||||
|
zarch facility = 1 // z architecture mode is active
|
||||||
|
stflef facility = 7 // store-facility-list-extended
|
||||||
|
ldisp facility = 18 // long-displacement
|
||||||
|
eimm facility = 21 // extended-immediate
|
||||||
|
|
||||||
|
// miscellaneous facilities
|
||||||
|
dfp facility = 42 // decimal-floating-point
|
||||||
|
etf3eh facility = 30 // extended-translation 3 enhancement
|
||||||
|
|
||||||
|
// cryptography facilities
|
||||||
|
msa facility = 17 // message-security-assist
|
||||||
|
msa3 facility = 76 // message-security-assist extension 3
|
||||||
|
msa4 facility = 77 // message-security-assist extension 4
|
||||||
|
msa5 facility = 57 // message-security-assist extension 5
|
||||||
|
msa8 facility = 146 // message-security-assist extension 8
|
||||||
|
msa9 facility = 155 // message-security-assist extension 9
|
||||||
|
|
||||||
|
// vector facilities
|
||||||
|
vx facility = 129 // vector facility
|
||||||
|
vxe facility = 135 // vector-enhancements 1
|
||||||
|
vxe2 facility = 148 // vector-enhancements 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// facilityList contains the result of an STFLE call.
|
||||||
|
// Bits are numbered in big endian order so the
|
||||||
|
// leftmost bit (the MSB) is at index 0.
|
||||||
|
type facilityList struct {
|
||||||
|
bits [4]uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has reports whether the given facilities are present.
|
||||||
|
func (s *facilityList) Has(fs ...facility) bool {
|
||||||
|
if len(fs) == 0 {
|
||||||
|
panic("no facility bits provided")
|
||||||
|
}
|
||||||
|
for _, f := range fs {
|
||||||
|
if !bitIsSet(s.bits[:], uint(f)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// function is the code for the named cryptographic function.
|
||||||
|
type function uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// KM{,A,C,CTR} function codes
|
||||||
|
aes128 function = 18 // AES-128
|
||||||
|
aes192 function = 19 // AES-192
|
||||||
|
aes256 function = 20 // AES-256
|
||||||
|
|
||||||
|
// K{I,L}MD function codes
|
||||||
|
sha1 function = 1 // SHA-1
|
||||||
|
sha256 function = 2 // SHA-256
|
||||||
|
sha512 function = 3 // SHA-512
|
||||||
|
sha3_224 function = 32 // SHA3-224
|
||||||
|
sha3_256 function = 33 // SHA3-256
|
||||||
|
sha3_384 function = 34 // SHA3-384
|
||||||
|
sha3_512 function = 35 // SHA3-512
|
||||||
|
shake128 function = 36 // SHAKE-128
|
||||||
|
shake256 function = 37 // SHAKE-256
|
||||||
|
|
||||||
|
// KLMD function codes
|
||||||
|
ghash function = 65 // GHASH
|
||||||
|
)
|
||||||
|
|
||||||
|
// queryResult contains the result of a Query function
|
||||||
|
// call. Bits are numbered in big endian order so the
|
||||||
|
// leftmost bit (the MSB) is at index 0.
|
||||||
|
type queryResult struct {
|
||||||
|
bits [2]uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has reports whether the given functions are present.
|
||||||
|
func (q *queryResult) Has(fns ...function) bool {
|
||||||
|
if len(fns) == 0 {
|
||||||
|
panic("no function codes provided")
|
||||||
|
}
|
||||||
|
for _, f := range fns {
|
||||||
|
if !bitIsSet(q.bits[:], uint(f)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
initS390Xbase()
|
||||||
|
|
||||||
|
// We need implementations of stfle, km and so on
|
||||||
|
// to detect cryptographic features.
|
||||||
|
if !haveAsmFunctions() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional cryptographic functions
|
||||||
|
if S390X.HasMSA {
|
||||||
|
aes := []function{aes128, aes192, aes256}
|
||||||
|
|
||||||
|
// cipher message
|
||||||
|
km, kmc := kmQuery(), kmcQuery()
|
||||||
|
S390X.HasAES = km.Has(aes...)
|
||||||
|
S390X.HasAESCBC = kmc.Has(aes...)
|
||||||
|
if S390X.HasSTFLE {
|
||||||
|
facilities := stfle()
|
||||||
|
if facilities.Has(msa4) {
|
||||||
|
kmctr := kmctrQuery()
|
||||||
|
S390X.HasAESCTR = kmctr.Has(aes...)
|
||||||
|
}
|
||||||
|
if facilities.Has(msa8) {
|
||||||
|
kma := kmaQuery()
|
||||||
|
S390X.HasAESGCM = kma.Has(aes...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute message digest
|
||||||
|
kimd := kimdQuery() // intermediate (no padding)
|
||||||
|
klmd := klmdQuery() // last (padding)
|
||||||
|
S390X.HasSHA1 = kimd.Has(sha1) && klmd.Has(sha1)
|
||||||
|
S390X.HasSHA256 = kimd.Has(sha256) && klmd.Has(sha256)
|
||||||
|
S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512)
|
||||||
|
S390X.HasGHASH = kimd.Has(ghash) // KLMD-GHASH does not exist
|
||||||
|
sha3 := []function{
|
||||||
|
sha3_224, sha3_256, sha3_384, sha3_512,
|
||||||
|
shake128, shake256,
|
||||||
|
}
|
||||||
|
S390X.HasSHA3 = kimd.Has(sha3...) && klmd.Has(sha3...)
|
||||||
|
}
|
||||||
|
}
|
58
vendor/golang.org/x/sys/cpu/cpu_s390x.s
generated
vendored
Normal file
58
vendor/golang.org/x/sys/cpu/cpu_s390x.s
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build gc
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func stfle() facilityList
|
||||||
|
TEXT ·stfle(SB), NOSPLIT|NOFRAME, $0-32
|
||||||
|
MOVD $ret+0(FP), R1
|
||||||
|
MOVD $3, R0 // last doubleword index to store
|
||||||
|
XC $32, (R1), (R1) // clear 4 doublewords (32 bytes)
|
||||||
|
WORD $0xb2b01000 // store facility list extended (STFLE)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func kmQuery() queryResult
|
||||||
|
TEXT ·kmQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||||
|
MOVD $0, R0 // set function code to 0 (KM-Query)
|
||||||
|
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||||
|
WORD $0xB92E0024 // cipher message (KM)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func kmcQuery() queryResult
|
||||||
|
TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||||
|
MOVD $0, R0 // set function code to 0 (KMC-Query)
|
||||||
|
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||||
|
WORD $0xB92F0024 // cipher message with chaining (KMC)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func kmctrQuery() queryResult
|
||||||
|
TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||||
|
MOVD $0, R0 // set function code to 0 (KMCTR-Query)
|
||||||
|
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||||
|
WORD $0xB92D4024 // cipher message with counter (KMCTR)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func kmaQuery() queryResult
|
||||||
|
TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||||
|
MOVD $0, R0 // set function code to 0 (KMA-Query)
|
||||||
|
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||||
|
WORD $0xb9296024 // cipher message with authentication (KMA)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func kimdQuery() queryResult
|
||||||
|
TEXT ·kimdQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||||
|
MOVD $0, R0 // set function code to 0 (KIMD-Query)
|
||||||
|
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||||
|
WORD $0xB93E0024 // compute intermediate message digest (KIMD)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func klmdQuery() queryResult
|
||||||
|
TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||||
|
MOVD $0, R0 // set function code to 0 (KLMD-Query)
|
||||||
|
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||||
|
WORD $0xB93F0024 // compute last message digest (KLMD)
|
||||||
|
RET
|
18
vendor/golang.org/x/sys/cpu/cpu_wasm.go
generated
vendored
Normal file
18
vendor/golang.org/x/sys/cpu/cpu_wasm.go
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
//go:build wasm
|
||||||
|
// +build wasm
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// We're compiling the cpu package for an unknown (software-abstracted) CPU.
|
||||||
|
// Make CacheLinePad an empty struct and hope that the usual struct alignment
|
||||||
|
// rules are good enough.
|
||||||
|
|
||||||
|
const cacheLineSize = 0
|
||||||
|
|
||||||
|
func initOptions() {}
|
||||||
|
|
||||||
|
func archInit() {}
|
145
vendor/golang.org/x/sys/cpu/cpu_x86.go
generated
vendored
Normal file
145
vendor/golang.org/x/sys/cpu/cpu_x86.go
generated
vendored
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build 386 || amd64 || amd64p32
|
||||||
|
// +build 386 amd64 amd64p32
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
const cacheLineSize = 64
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "adx", Feature: &X86.HasADX},
|
||||||
|
{Name: "aes", Feature: &X86.HasAES},
|
||||||
|
{Name: "avx", Feature: &X86.HasAVX},
|
||||||
|
{Name: "avx2", Feature: &X86.HasAVX2},
|
||||||
|
{Name: "avx512", Feature: &X86.HasAVX512},
|
||||||
|
{Name: "avx512f", Feature: &X86.HasAVX512F},
|
||||||
|
{Name: "avx512cd", Feature: &X86.HasAVX512CD},
|
||||||
|
{Name: "avx512er", Feature: &X86.HasAVX512ER},
|
||||||
|
{Name: "avx512pf", Feature: &X86.HasAVX512PF},
|
||||||
|
{Name: "avx512vl", Feature: &X86.HasAVX512VL},
|
||||||
|
{Name: "avx512bw", Feature: &X86.HasAVX512BW},
|
||||||
|
{Name: "avx512dq", Feature: &X86.HasAVX512DQ},
|
||||||
|
{Name: "avx512ifma", Feature: &X86.HasAVX512IFMA},
|
||||||
|
{Name: "avx512vbmi", Feature: &X86.HasAVX512VBMI},
|
||||||
|
{Name: "avx512vnniw", Feature: &X86.HasAVX5124VNNIW},
|
||||||
|
{Name: "avx5124fmaps", Feature: &X86.HasAVX5124FMAPS},
|
||||||
|
{Name: "avx512vpopcntdq", Feature: &X86.HasAVX512VPOPCNTDQ},
|
||||||
|
{Name: "avx512vpclmulqdq", Feature: &X86.HasAVX512VPCLMULQDQ},
|
||||||
|
{Name: "avx512vnni", Feature: &X86.HasAVX512VNNI},
|
||||||
|
{Name: "avx512gfni", Feature: &X86.HasAVX512GFNI},
|
||||||
|
{Name: "avx512vaes", Feature: &X86.HasAVX512VAES},
|
||||||
|
{Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2},
|
||||||
|
{Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG},
|
||||||
|
{Name: "avx512bf16", Feature: &X86.HasAVX512BF16},
|
||||||
|
{Name: "bmi1", Feature: &X86.HasBMI1},
|
||||||
|
{Name: "bmi2", Feature: &X86.HasBMI2},
|
||||||
|
{Name: "cx16", Feature: &X86.HasCX16},
|
||||||
|
{Name: "erms", Feature: &X86.HasERMS},
|
||||||
|
{Name: "fma", Feature: &X86.HasFMA},
|
||||||
|
{Name: "osxsave", Feature: &X86.HasOSXSAVE},
|
||||||
|
{Name: "pclmulqdq", Feature: &X86.HasPCLMULQDQ},
|
||||||
|
{Name: "popcnt", Feature: &X86.HasPOPCNT},
|
||||||
|
{Name: "rdrand", Feature: &X86.HasRDRAND},
|
||||||
|
{Name: "rdseed", Feature: &X86.HasRDSEED},
|
||||||
|
{Name: "sse3", Feature: &X86.HasSSE3},
|
||||||
|
{Name: "sse41", Feature: &X86.HasSSE41},
|
||||||
|
{Name: "sse42", Feature: &X86.HasSSE42},
|
||||||
|
{Name: "ssse3", Feature: &X86.HasSSSE3},
|
||||||
|
|
||||||
|
// These capabilities should always be enabled on amd64:
|
||||||
|
{Name: "sse2", Feature: &X86.HasSSE2, Required: runtime.GOARCH == "amd64"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func archInit() {
|
||||||
|
|
||||||
|
Initialized = true
|
||||||
|
|
||||||
|
maxID, _, _, _ := cpuid(0, 0)
|
||||||
|
|
||||||
|
if maxID < 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, ecx1, edx1 := cpuid(1, 0)
|
||||||
|
X86.HasSSE2 = isSet(26, edx1)
|
||||||
|
|
||||||
|
X86.HasSSE3 = isSet(0, ecx1)
|
||||||
|
X86.HasPCLMULQDQ = isSet(1, ecx1)
|
||||||
|
X86.HasSSSE3 = isSet(9, ecx1)
|
||||||
|
X86.HasFMA = isSet(12, ecx1)
|
||||||
|
X86.HasCX16 = isSet(13, ecx1)
|
||||||
|
X86.HasSSE41 = isSet(19, ecx1)
|
||||||
|
X86.HasSSE42 = isSet(20, ecx1)
|
||||||
|
X86.HasPOPCNT = isSet(23, ecx1)
|
||||||
|
X86.HasAES = isSet(25, ecx1)
|
||||||
|
X86.HasOSXSAVE = isSet(27, ecx1)
|
||||||
|
X86.HasRDRAND = isSet(30, ecx1)
|
||||||
|
|
||||||
|
var osSupportsAVX, osSupportsAVX512 bool
|
||||||
|
// For XGETBV, OSXSAVE bit is required and sufficient.
|
||||||
|
if X86.HasOSXSAVE {
|
||||||
|
eax, _ := xgetbv()
|
||||||
|
// Check if XMM and YMM registers have OS support.
|
||||||
|
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
|
||||||
|
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
// Darwin doesn't save/restore AVX-512 mask registers correctly across signal handlers.
|
||||||
|
// Since users can't rely on mask register contents, let's not advertise AVX-512 support.
|
||||||
|
// See issue 49233.
|
||||||
|
osSupportsAVX512 = false
|
||||||
|
} else {
|
||||||
|
// Check if OPMASK and ZMM registers have OS support.
|
||||||
|
osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
X86.HasAVX = isSet(28, ecx1) && osSupportsAVX
|
||||||
|
|
||||||
|
if maxID < 7 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, ebx7, ecx7, edx7 := cpuid(7, 0)
|
||||||
|
X86.HasBMI1 = isSet(3, ebx7)
|
||||||
|
X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX
|
||||||
|
X86.HasBMI2 = isSet(8, ebx7)
|
||||||
|
X86.HasERMS = isSet(9, ebx7)
|
||||||
|
X86.HasRDSEED = isSet(18, ebx7)
|
||||||
|
X86.HasADX = isSet(19, ebx7)
|
||||||
|
|
||||||
|
X86.HasAVX512 = isSet(16, ebx7) && osSupportsAVX512 // Because avx-512 foundation is the core required extension
|
||||||
|
if X86.HasAVX512 {
|
||||||
|
X86.HasAVX512F = true
|
||||||
|
X86.HasAVX512CD = isSet(28, ebx7)
|
||||||
|
X86.HasAVX512ER = isSet(27, ebx7)
|
||||||
|
X86.HasAVX512PF = isSet(26, ebx7)
|
||||||
|
X86.HasAVX512VL = isSet(31, ebx7)
|
||||||
|
X86.HasAVX512BW = isSet(30, ebx7)
|
||||||
|
X86.HasAVX512DQ = isSet(17, ebx7)
|
||||||
|
X86.HasAVX512IFMA = isSet(21, ebx7)
|
||||||
|
X86.HasAVX512VBMI = isSet(1, ecx7)
|
||||||
|
X86.HasAVX5124VNNIW = isSet(2, edx7)
|
||||||
|
X86.HasAVX5124FMAPS = isSet(3, edx7)
|
||||||
|
X86.HasAVX512VPOPCNTDQ = isSet(14, ecx7)
|
||||||
|
X86.HasAVX512VPCLMULQDQ = isSet(10, ecx7)
|
||||||
|
X86.HasAVX512VNNI = isSet(11, ecx7)
|
||||||
|
X86.HasAVX512GFNI = isSet(8, ecx7)
|
||||||
|
X86.HasAVX512VAES = isSet(9, ecx7)
|
||||||
|
X86.HasAVX512VBMI2 = isSet(6, ecx7)
|
||||||
|
X86.HasAVX512BITALG = isSet(12, ecx7)
|
||||||
|
|
||||||
|
eax71, _, _, _ := cpuid(7, 1)
|
||||||
|
X86.HasAVX512BF16 = isSet(5, eax71)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(bitpos uint, value uint32) bool {
|
||||||
|
return value&(1<<bitpos) != 0
|
||||||
|
}
|
28
vendor/golang.org/x/sys/cpu/cpu_x86.s
generated
vendored
Normal file
28
vendor/golang.org/x/sys/cpu/cpu_x86.s
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
//go:build (386 || amd64 || amd64p32) && gc
|
||||||
|
// +build 386 amd64 amd64p32
|
||||||
|
// +build gc
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
|
||||||
|
TEXT ·cpuid(SB), NOSPLIT, $0-24
|
||||||
|
MOVL eaxArg+0(FP), AX
|
||||||
|
MOVL ecxArg+4(FP), CX
|
||||||
|
CPUID
|
||||||
|
MOVL AX, eax+8(FP)
|
||||||
|
MOVL BX, ebx+12(FP)
|
||||||
|
MOVL CX, ecx+16(FP)
|
||||||
|
MOVL DX, edx+20(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func xgetbv() (eax, edx uint32)
|
||||||
|
TEXT ·xgetbv(SB),NOSPLIT,$0-8
|
||||||
|
MOVL $0, CX
|
||||||
|
XGETBV
|
||||||
|
MOVL AX, eax+0(FP)
|
||||||
|
MOVL DX, edx+4(FP)
|
||||||
|
RET
|
10
vendor/golang.org/x/sys/cpu/cpu_zos.go
generated
vendored
Normal file
10
vendor/golang.org/x/sys/cpu/cpu_zos.go
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func archInit() {
|
||||||
|
doinit()
|
||||||
|
Initialized = true
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue