Commit Graph

219 Commits

Author SHA1 Message Date
saurori 89d392d274 Fix large RSA exponent check (#481) 2017-03-29 21:52:38 +02:00
Miek Gieben 01a32dc202 Re-gen zcompress.go (#461)
and add one golint/doc fix intoit.
2017-02-17 11:59:01 +00:00
Miek Gieben 5a15a35f5f Golint fixes (#456)
Fixes #370
2017-02-15 20:40:16 +00:00
Tom Thorogood 8060d9f513 Improve DNSSEC performance by addressing some low hanging fruit. (#446)
* Produce less garbage in dnssec.go.

This change removes several needless append calls.

This is a minor performance improvement and will likely go
entirely unnoticed. The changes will reduce the amount of
garbage produced when calling (*DNSKEY).ToDS, (*RRSIG).Sign
and (*RRSIG).Verify.

* Minor performance improvement in RSA DNSSEC key generation.

This change ensures that (*big.Int).Bytes is only called once in
exponentToBuf because each call has non-zero overhead. It also
makes buf large enough to append without a second allocation.

exponentToBuf is invoked by (*DNSKEY).setPublicKeyRSA which is in
turn invoked by (*DNSKEY).Generate when (*DNSKEY).Algorithm is set
to an RSA* constant.

This is a minor performance improvement that will likely go
entirely unnoticed. The changes will improve the performance and
reduce the ammount of garbage produced when calling
(*DNSKEY).Generate.
2017-02-03 12:34:08 +00:00
Miek Gieben b51e305bc6 Remove reflection (#376)
Everything is generated. Remove all uses of packStruct/unpackStruct and
make the library reflectionless.
2016-06-12 21:06:46 +01:00
Michael Haro a465e84f54 Use encoding/binary's conversion functions when possible. (#364)
* Remove {un,}packUint{16,32}Msg functions.

unpackUint16Msg unpackUint32Msg packUint16Msg packUint32Msg implemented
functionality that is part of the encoding/binary package.

* Use encoding/binary's encoding in more places.
2016-06-08 16:38:42 +01:00
Miek Gieben 475ab80867 Remove (most) reflection
Remove the use of reflection when packing and unpacking, instead
generate all the pack and unpack functions using msg_generate.
This will generate zmsg.go which in turn calls the helper functions from
msg_helper.go.

This increases the speed by about ~30% while cutting back on memory
usage. Not all RRs are using it, but that will be rectified in upcoming
PR.

Most of the speed increase is in the header/question section parsing.
These functions *are* not generated, but straight forward enough. The
implementation can be found in msg.go.

The new code has been fuzzed by go-fuzz, which turned up some issues.

All files that started with 'z', and not autogenerated were renamed,
i.e. zscan.go is now scan.go.

Reflection is still used, in subsequent PRs it will be removed entirely.
2016-06-03 12:45:22 +01:00
Miek Gieben 373b848617 HINFO does not need downcasing for DNSSEC
See the comment from Andrew:
https://github.com/miekg/dns/pull/270#issuecomment-145696618
2015-10-06 07:59:47 +01:00
Filippo Valsorda e9635cc83b Fix (*HINFO).len() and HINFO canonicalization in rawSignatureData 2015-10-05 14:37:42 +01:00
Filippo Valsorda 034c247229 Refactor DNSSEC to use crypto.{PrivateKey,Signer}
This will allow RRSIG.Sign to use generic crypto.Signer implementations.

This is a interface breaking change, even if the required changes are most
likely just type asserions from crypto.PrivateKey to the underlying type or
crypto.Signer.
2015-08-19 17:51:02 +01:00
Aaron Lehmann 2cee5e58b0 Rename isValidRRSet to IsRRset, and move it to defaults.go 2015-06-28 17:04:05 -07:00
Aaron Lehmann f605c832f0 Remove isValidRRSet check from RRSIG Sign method
Change suggested by miekg, since the caller may already know it's
passing a proper RRset.

Update unit test to call isValidRRSet directly instead of expecting Sign
to return an error for sets the fail the check.
2015-06-28 16:57:40 -07:00
Aaron Lehmann dc56846101 Check that the RRs passed to Sign and Verify form a valid RFC2181 RRSet
Add a sanity check used by RRSig's Sign and Verify functions making sure
that the records they operate on form a valid RRSet (same name, type,
and class).

Add a unit test TestInvalidRRSet that calls RRSig's Sign and Verify
methods with invalid RRSets, and makes sure the correct error is
returned.
2015-06-04 11:13:49 -07:00
Filippo Valsorda 4657816178 Add ToCDNSKEY and ToCDS methods (+bugfix) 2015-04-10 18:54:04 +01:00
Filippo Valsorda 315e7334de RRSIG.Sign: remove duplicate before signing records as per RFC 2015-03-17 14:34:16 +00:00
Miek Gieben 64fea017a2 Move all docs to docs.go
Another golint change.
2015-02-19 13:47:50 +00:00
Miek Gieben 67945c119e A bunch of golint fixes
The proposed vars names are a nono, because they break the API.
Things left: document each RR and zscan_rr.go has some funcky if-then-elses.
2015-02-19 09:58:33 +00:00
Filippo Valsorda 3035815b29 Reorder DNSSEC code 2015-01-23 13:06:08 -08:00
Filippo Valsorda e9faa971b3 Refactor the DNSSEC private key code
Now PrivateKey is an interface exposing Sign() and String(). Common
implementations are wrappers for {rsa|dsa|ecdsa}.PrivateKey but
this allows for custom signers, and abstracts away the private-ops
code to a single place.
2015-01-23 13:04:29 -08:00
Filippo Valsorda c47471f80e [DNSSEC] Make int to bytes conversions fixed length in DSA (RFC 2536)
This fixes DSA key generation.
2014-12-06 10:26:56 +00:00
Filippo Valsorda ed475ae9fa [DNSSEC] Make int to bytes conversions fixed length in ECDSA
ECDSA public keys consist of a single value, called "Q" in FIPS
  186-3.  In DNSSEC keys, Q is a simple bit string that represents the
  uncompressed form of a curve point, "x | y".

  The ECDSA signature is the combination of two non-negative integers,
  called "r" and "s" in FIPS 186-3.  The two integers, each of which is
  formatted as a simple octet string, are combined into a single longer
  octet string for DNSSEC as the concatenation "r | s".  (Conversion of
  the integers to bit strings is described in Section C.2 of FIPS
  186-3.)  For P-256, each integer MUST be encoded as 32 octets; for
  P-384, each integer MUST be encoded as 48 octets.
2014-12-05 20:17:11 +00:00
Filippo Valsorda 0f1b1184ae Rename and simplify packing helper functions 2014-12-05 19:27:44 +00:00
Miek Gieben a34d1f6ad7 Merge branch 'master' of github.com:miekg/dns 2014-11-03 11:02:31 +00:00
Andrew Tunnell-Jones 5bccac1c47 Fix off-by-one error parsing DSA public key
I ran into a slice bounds out of range panic. Tired so I just rewrote it.
2014-11-01 10:54:01 +00:00
Miek Gieben 71466895f7 Remove ECC which was set as alg 4
There is no alg 4 and ECC is not an algorithm identifier.
2014-10-23 08:12:02 +00:00
Alex A Skinner c417e9729d DNSSEC algorithm and digest types now uint8 2014-10-22 20:41:03 -04:00
Miek Gieben 0aa3021a83 Remove all copyright notices
Use the central COPYRIGHT file.
2014-09-11 20:57:37 +01:00
Miek Gieben 643720d10d Fix ECDSA algorithms
Current code was completely wrong, so validation of ECDSA didn't work.
The new tests now works, the old one now doesn't
2014-09-09 07:45:47 +01:00
Filippo Valsorda 3a7db158f5 Correct the DNSKEY flag values
See https://www.iana.org/assignments/dnskey-flags/dnskey-flags.xhtml

Elsewhere in the code 256 (1 << 8) is used numerically for ZONE, so nothing breaks for now.
2014-09-04 15:31:23 -07:00
Alex A. Skinner a156d1ec2f must lowercase ownername when computing hash for DS 2014-04-10 19:40:52 -04:00
Miek Gieben fb787f0d96 Update the documentation 2014-02-02 20:30:52 +00:00
Miek Gieben 9c75b3cdc2 Fi the tests too 2014-01-27 14:45:34 +00:00
Miek Gieben 39a8e2b8af Small api change to check RRSIG validity 2014-01-27 14:42:17 +00:00
Miek Gieben c97bb6d79d The right way around 2014-01-26 20:22:19 +00:00
Miek Gieben 2a659fce45 dnssec: don't override OrigTtl in sig
When creating a signature and the OrigTtl is already set
don't override it.
2014-01-26 19:53:49 +00:00
Miek Gieben 6b32a711e9 Allocate just enough space
Remove the len()*2, and replace it with len()+1. The current
len() impl. of the types is good enough to be more precise.
2013-12-06 11:30:33 +00:00
Miek Gieben 70ee966106 Fix the unknown record sign test
Don't make up new error in msg.Pack when there are perfectly fine
errors to return.
2013-12-06 09:43:26 +00:00
Skinner, Alex edd235088a Added TYPE65534 record type so that zone scanning doesn't die upon encountering one. Fixed DNSSEC signature verification. 2013-12-04 12:58:20 -05:00
Miek Gieben ee8ace0477 Merge branch 'master' of github.com:miekg/dns 2013-09-11 08:22:23 +01:00
Miek Gieben 9c1ee5d5ca Update IsDomainName
This new functions just compiles the domain to wire format, if that
works, the name is deemed OK. It is also much less strict than the
older code. Almost everything is allowed in the name, except two
dots back to back (there is an explicit test for that).
2013-09-10 18:09:22 +00:00
Miek Gieben 47cc5b052d Work on making IsDomainName better 2013-09-10 13:13:10 +00:00
Miek Gieben cb70138d9e Remove comment 2013-09-01 21:37:14 +01:00
Miek Gieben 38ea608d79 Rename the Label* functions
SplitLabels -> SplitDomainName
CompareLabels -> CompareDomainName
LenLabels -> CountLabel
          -> NextLabel was added as a simple iterator-like function
2013-06-22 07:21:15 +00:00
Miek Gieben c66494c6c5 Resolv merge conflicts 2013-05-12 19:08:37 +02:00
Miek Gieben 81941d4422 Update all copyright notices 2013-05-12 16:15:52 +02:00
Miek Gieben 320d981509 Add Algo-signal-draft impl. for EDNS0 2013-05-11 21:02:17 +02:00
Miek Gieben d53d9eab81 gofmt 2013-05-05 20:30:44 +02:00
Miek Gieben cd10853288 Make Len() and Copy() private
I don't think anybody will needs these, msg.Len() is still
available. Severly cuts back on the amount of exported functions.
2013-02-09 08:35:17 +01:00
Miek Gieben 235e892dfc Rename the RR types drop the RR_ prefix
This is also done in the official Go library. It also make the
code shorter.
2012-12-09 19:23:25 +01:00
Miek Gieben 2a3b818b95 Use much more descriptive names for the maps
Alg_str -> AlgorithmToString
 Rr_str  -> TypeToString

And for the reverse maps also.
2012-12-02 09:29:54 +01:00