aboutsummaryrefslogtreecommitdiff
path: root/lib/email/dkim
AgeCommit message (Collapse)Author
10 daysall: apply go fixShulhan
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2025-02-04all: remove the nolint tagsShulhan
The "nolint" tag is used to ignore lines from being processed by golangci-lint. Since we are not using golangci-lint anymore, now and in the future, those lines can be removed.
2025-01-23all: use for-range with numericShulhan
Go 1.22 now support for-range on numeric value.
2024-03-05all: comply with linter recommendations #3Shulhan
For HTTP server that use TLS, set the minimum TLS version and ReadHeaderTimeout to mitigate slowloris attack. For HTTP client or server that parameterize the use of InsecureSkipVerify, annotate the line with "nolint:gosec" to allow the code pass the check. Library that still use sha1, in example in DKIM and TOTP, skip the warnings by annotating the line with "nolint:gosec". A pointer variable now allocated their address before assigning its value. Any error that returned now wrapped using "%w". Also, replace error checking using [errors.Is] or [errors.As] instead of using equal or not-equal operators. In "lib/http", replace any usage of "math/rand" with "crypto/rand". Any call of [math/big.Rat.SetString] now annotated with "nolint:gosec" since its false positive, the issue has been fixed in Go >= 1.17.7. Any switch case that does not cover the rest of the possible values now handled by adding the cases or by replacing the "default" case with the rest of values.
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-11-07email/dkim: set ExpiredAtto MaxInt64 if value is greater than 12 digitsShulhan
According to RFC 6376, To avoid denial-of-service attacks, implementations MAY consider any value longer than 12 digits to be infinite. Since ExpiredAt type is uint64, we cannot set it to infinite, so set it to maximum value int64 (not maximum of uint64).
2023-09-11email/dkim: realign struct for better size allocationShulhan
The realignment reduce the cost of the following struct, * struct in TestNewDNSClientPool: from 64 to 56 bytes (-8 bytes) * Key: from 160 to 144 bytes (-16 bytes) * struct in TestKeyParseTXT: from 48 to 40 bytes (-8 bytes) * KeyPool: from 16 to 8 bytes (-8 bytes) * Signature: from 256 to 240 bytes (-16 bytes) * struct in TestSignatureHash: from 48 to 40 bytes (-8 bytes) * struct in TestSignatureSign: from 80 to 64 bytes (-16 bytes) * struct in TestSignatureVerify: from 72 to 64 bytes (-8 bytes) * Status: from 48 to 24 bytes (-24 bytes) * tag: from 16 to 8 bytes (-8 bytes)
2023-04-08email/dkim: replace lib/io#Reader with lib/bytes#ParserShulhan
The libio.Reader will be deprecated and replaced with libbytes.Parser in the future.
2022-10-05email/dkim: fix tests with -count=X, where X>1Shulhan
2022-07-16email/dkim: skip test that require external DNS recordsShulhan
Due to external DNS records are unpredictable, some test may failed in the future.
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2022-04-06all: replace any usage of ioutil package with os or ioShulhan
Since Go 1.16, the ioutil package has been deprecated. This changes replace any usage that use functions from ioutil package with their replacement from package os or package io.
2022-03-21email/dkim: remove amazonses.com domain from test casesShulhan
The domain now return invalid public key record, so we removed them to make the test passed for now.
2021-11-16lib/dns: refactoring, change signature of client LookupShulhan
Previously, Lookup() method on Client pass the question name, type, and class as parameters. This changes make those parameters into MessageQuestion.
2021-11-15lib/{email,spf}: changes related to refactoring lib/dnsShulhan
2021-03-14all: refactoring the test.Assert and test.AssertBench signatureShulhan
Previously, the test.Assert and test.AssertBench functions has the boolean parameter to print the stack trace of test in case its not equal. Since this parameter is not mandatory and its usually always set to "true", we remove them from function signature to simplify the call to Assert and AssertBench.
2020-08-15dns: refactoring the ResourceRecord values from []byte to stringShulhan
There are two reasons for this changes. First, to allow JSON encoded of ResourceRecord.Value without encoded to base64. Second, to minimize unreleased packet due to the backing storage is still used when assigned to Value (or any []byte field in RDataXXX).
2020-08-03all: fix tests affected by changes on dns packageShulhan
2020-06-06all: use default linter optionsShulhan
2020-05-16all: fix and suppress linter warningsShulhan
2020-03-20dkim: convert the expired time to UTC on errorShulhan
This fix flaky test issue on macOS that display expired time in local time.
2020-03-20dkim: skip test that use external DNSShulhan
TODO: replace DNS with local server.
2020-01-20email/dkim: fix the expected test result and errorsShulhan
2019-11-05email/dkim: fix the test expected response on LookupDNSTXTShulhan
2019-09-05all: fix test for Go 1.13Shulhan
2019-06-14ascii: new library for working with ASCII charactersShulhan
This library previously part of bytes package. To make it bytes package consistent (only working with slice of byte), we move all ASCII related constants, variables, and functions into new package.
2019-06-14all: fix nolint formatShulhan
The valid syntax to suppress linter warnings is "//nolint:<name>" with no space between comment and "nolint" and between ":". Also, we move the placement of nolint directive to the top of statements for multiple nolint in the same scope. While at it, fix and supress some linter warnings.
2019-05-07email: changes affected by update on dns packageShulhan
2019-03-01all: fix warnings from linterShulhan
Most of the warnings caused by update to linter which cause global variables declared with grouping "( ... )" and that has been suppressed, are become false-positive again.
2019-02-15email/dkim: fix warnings from lintersShulhan
2019-02-15all: fix the usage of "iota"Shulhan
Since most of constants is not required to be overlap (two or more state in one variable), we can simplify the declaration of iota without using shift left.
2019-02-15email: implement signing message with DKIM methodShulhan
Everything seems like works in order, we need more test will real life message.
2019-02-14email: implement DKIM verify on messageShulhan
Each message will have DKIMSignature field and dkimStatus that contains the message signature, if available, and their status.
2019-02-13email/dkim: rename "verifyXxx" methods to "validateXxx"Shulhan
The meaning of verify is for verifying the signature later with the message.
2019-02-11email/dkim: rename Verify method to ValidateShulhan
The name of "Verify" may confuse reader with DKIM verify process.
2019-02-09email/dkim: split parsing canonicalization value into its own functionsShulhan
2019-02-09email/dkim: split the DNS related functions into new fileShulhan
Also, add more unit test for creating DNS client pool.
2019-02-09email/dkim: various fixes with more unit testsShulhan
* HashAlg: Add unit test for unpacking hash algorithms. * Key, * make Type to be nil-able. Nil value on Type means its not defined and will not print the default when packing; * check for empty parameter on ParseTXT and lookupDNSTXT; * check for DNS message response code; and * make the Pack() method return compact text, without printing default key value. * KeyFlag: prevent duplicate flags. * Signature, * check the value immediately on set(); * add more unit test cases.
2019-02-08email/dkim: add key poolShulhan
Implementor of this library can use the KeyPool.Get method to retrieve key instead of LookupKey to minimize network traffic and process to decode and parse public key. This changes affect how we call LookupKey.
2019-02-08email/dkim: decode and parse public key from TXT recordShulhan
2019-02-08email/dkim: handle invalid characters when parsing tag value with base64Shulhan
2019-02-07email/dkim: fix linter warnings on global variablesShulhan
Also, comment the global variables to describe their meanings.
2019-02-07email/dkim: implement public key lookup with DNSShulhan
This implementation is based on RFC 6376 section 3.6 Key Management and Representation.
2019-02-07email/dkim: add type for query method that combine query type and optionShulhan
A single query method is required for function to lookup public key.
2019-02-06lib/email/dkim: new package for parsing and creating DKIM signatureShulhan
While at it, update documentation on DKIM Signatures.