更新ログ
v1.3.0 (2026-10-19)
✨ 新機能
Sm2にASN.1形式の暗号文と署名形式を追加:Sm2CipherModeにASN1C1C2C3とASN1C1C3C2を追加し、暗号文を DER のSEQUENCE { x INTEGER, y INTEGER, C2 OCTET STRING, C3 OCTET STRING }として扱えるようになりました。BouncyCastle、Java、多くの国密ゲートウェイが出力する形式で、従来のC1 || C2 || C3、C1 || C3 || C2という生バイトの並びに限定されません。あわせてSm2SingMode(既定はASN1、Bytesも選択可)とSetSingModeを追加し、署名は DER のSEQUENCE { r, s }または固定 64 バイトのr || sになります。どちらもcryptobyteで解析するため、切り詰められたデータや DER でないデータは黙って誤読されずエラーを返します。NewSm2KeyPairの既定値はASN1のままです(by @Web-Coke in #40)- モールス符号表を ITU-R M.1677-1 の全表と国際拡張文字に拡張:
¡、¿、å/Å、ä/Ä、é/É、ñ/Ñ、ó/Ó、ö/Ö、ú/Úを追加し、符号は codigomorse.org に準拠、各グループが対応する ITU 条項も明記しました。/は句読点グループに移動しています。注意:既存の 2 つのマッピングが変わります。<は.--.-から.--.--へ(.--.-はåに割り当て)、\nは.-..-..へ変更され\rと符号を共有しなくなります。v1.2.3でエンコードしたこれらの文字はデコード結果が変わります(by @htlsmilework in #42)
🐛 修正
z省略形がある場合に ascii85 デコードの出力が切り詰められるバグを修正:encoding/ascii85は全ゼロの 4 バイトグループを単一のzに変換し、本ライブラリのエンコーダーも同様ですが、デコーダーは文字数から 5:4 の比率で出力長を再計算し、標準ライブラリの正しい結果をその長さに切り詰めていました。そのため 5 ゼロバイトが 2 バイトに、8 ゼロバイトが 1 バイトになり、しかもエラーは返りませんでした。現在はzをこの比率から除外して 4 バイトとして数え、省略形が含む展開量に応じて出力バッファを確保します(by @youdie006 in #44)- ゼログループが 4 つ以上ある場合に ascii85 デコードが失敗するバグを修正:上記の長さ修正後も
uのパディングがlen(src)%5を使っており、z省略形があると最後のグループが 1 文字だけになることがありました。encoding/ascii85はこの入力を拒否するため、16 ゼロバイト(zzzzとエンコード)はまったくデコードできませんでした。現在は 2 つのデコーダーともz以外の長さでパディングします(by @youdie006 in #47) - base58、base62 のストリーム処理結果がバッチ API と一致しないバグを修正:どちらの符号化も入力を 1 つの大きな整数として扱うため独立したブロックに分割できませんが、ストリームエンコーダーは 8 バイトずつ、ストリームデコーダーは 1024 バイトずつ処理していました。その結果
Encode.FromFile(...).ByBase58()、ByBase62()は同じデータのFromBytes()と異なる結果を返し、しかもその結果は元に戻せませんでした。現在はドキュメントの記載どおりストリームエンコーダーが入力をバッファリングしてCloseで一度にエンコードし、デコーダーは入力全体を読み込んで一度にデコードし、消費に合わせてバッファを解放します(by @Shaisolaris in #48) - 鍵ペアが他ツール生成の鍵を受け付けず、アルゴリズム不一致で panic するバグを修正:以前は
GenKeyPairの出力とバイト単位で一致する鍵(PUBLIC KEY/PRIVATE KEYPEM ブロックに PKIX または PKCS#8 DER を格納したもの)だけを受け付けていました。多くの SM2、Ed25519 生成器が出力する base64 や生の鍵素材はinvalid public key: <nil>や不可解な ASN.1 エラーで失敗し、RSA の鍵を Ed25519 鍵ペアに渡すと型アサーションの結果を検査していないため panic していました(#41)。現在はすべてのParse*、Format*、Set*メソッドが共通のセレクタを通り、PEM、base64(4 種類のアルファベット、パディングあり/なし)、16 進数、生の鍵素材を順に試し、各アルゴリズムのパーサーが成立する解釈を選びます。Ed25519 は PKIX/PKCS#8 DER、32 バイトのシード、64 バイトの秘密鍵を、SM2 は PKIX/PKCS#8 DER、65 バイトの非圧縮点、32 バイトのスカラーを、RSA は PKIX/PKCS#1 DER を受け付けます。SM2 の鍵フォーマットはcrypto/x509が SM2 を扱えないためローカルの SPKI/PKCS#8 エンコーダーに置き換え、出力は OpenSSL、Java で引き続き解析できます。Set*Keyは PEM を受け取って正規化し、アルゴリズムや向きが異なるブロックは解析前にUnsupportedKeyFormatError(the parsed key is an RSA key, not an Ed25519 key)で拒否します。エラーメッセージから<nil>が消え、Compress*Keyは文字列操作ではなくpem.Decodeを使うため任意のヘッダーを扱えます。SM2 の秘密鍵スカラーは[1, n-1]の範囲を検証するようになりました(以前はd = 0で公開点を持たない鍵が生成されました)(by @gouguolei in 012269d)
⚡ パフォーマンス
- モールスデコードで逆引き表を 1 度だけ構築し、記号ごとの走査を廃止:
StdDecoder.Decodeは記号ごとにStdAlphabet全体を走査して一致する符号を探していたため、デコードは O(n) ではなく O(n × 89) になり、CPU プロファイルの 53% を map の反復が占めていました。base45、base91 と同じくinit()で逆引き表を一度だけ構築するようにし、幾何平均で 89.21% 短縮(4096 文字:1222µs → 103µs)、割り当て回数は変わりません。この走査は結果の非決定性も招いていました。7 つの符号が大文字と小文字の組で共有されており(.--.-はÅとå、ä、é、ñ、ó、ö、úも同様)、map の反復順はランダムなため.--.-は 62% の確率でÅにデコードされ、これらの文字はエンコード後に元へ戻せませんでした。逆引き表はこの衝突を小文字に統一し、これはEncodeが生成しうる唯一の形式です(by @darakanoit in #46)
🔧 リファクタリング
- 鍵のシリアライズをパッケージレベルの関数変数に集約:
marshalPKIXPublicKey、marshalPKCS8PrivateKeyはcrypto/x509を包む変数になり、marshalSm2PublicKey、marshalSm2PrivateKeyはローカルの SM2 エンコーダーを包みます。これによりFormat*Keyのエラー分岐をテストで再現できます(型付きの鍵に対してcrypto/x509は決して失敗しないため)。RSA、Ed25519、SM2 のフォーマットはすべてこれらを経由します(by @gouguolei in e314c99 6ad47b4 0769ea0 2c9ad5a) - RSA ストリーム検証を簡素化し、未使用のストリームバッファを削除:
rsa.StreamVerifier.verifyはエラーが nil なら常に true だったvalidを返さずerrorのみを返します。unicode.StreamEncoder、unicode.StreamDecoderから未使用の固定[512]byteバッファを削除し、モールスのエラーメッセージはプレースホルダーのないfmt.Sprintfではなく文字列リテラルを使います(by @gouguolei in 68dad92) SetSingModeの逆のアサーションを修正し、SM2 の既定値を明示的に初期化:clamp テストはSetSingMode(Bytes)の後もSingModeがASN1のままであることを期待していましたが、setter は単に代入するため成立しません。またNewSm2KeyPairはゼロ値が偶然ASN1であることに依存していました。現在はコンストラクタがSingMode: ASN1を明示的に設定し、テストは両方向を検証します(by @gouguolei in 079efab)- テストの整理と拡充:24 のテストファイルから未使用の変数と重複ケースを削除し、
key_format_test.go、key_test.goを追加して鍵素材のヘルパー、各種UnsupportedKeyFormatErrorのメッセージ、公開 API の拒否経路、SM2 の DER と秘密鍵スカラー範囲の分岐をカバーしました。keypairのステートメントカバレッジは 97.7% に向上しています(by @gouguolei in 372209d 12c3e11)
🚀 CI
- golangci-lint のワークフローと設定を追加:
lint.ymlは master への push と pull request でv2.15.0に固定したgolangci-lint-action@v9を実行し、権限はcontents: readのみです。.golangci.ymlは標準セットにmisspell、unconvert、unparam、whitespaceを加え、主観の強いstaticcheckのスタイル検査(ST1000–ST1022、QF1001)を無効化し、errcheckから(io.Seeker).Seekを除外します(ストリームの巻き戻しは設計上ベストエフォートのため)。README は Go Report Card のバッジをこのワークフローのステータスバッジに置き換えました(by @gouguolei in 1487675 0517244)
📝 ドキュメント
- README の画像をリポジトリから配信し、ドキュメントサイトへの依存を解消:ロゴ、GVP と G-Star のバナー、JetBrains のロゴは
assets/を参照するようになり、英語、中国語、日本語の README はdongle.go-pkg.comに依存しなくなりました(by @gouguolei in 19bffd5)
What's Changed (19)
- add ASN.1 support by @Web-Coke in #40
- fix(morse): Add some code from codigomorse.org and correct some repetitive code by @htlsmilework in #42
- Decode the ascii85 z shortcut without truncating by @youdie006 in #44
- perf(morse): Derive the reverse alphabet once instead of scanning it per symbol by @darakanoit in #46
- Pad the ascii85 partial group without counting z shortcuts by @youdie006 in #47
- fix(coding): encode and decode base58 and base62 streams as a whole by @Shaisolaris in #48
- fix(keypair): correct SingMode test assertion and add explicit default by @gouguolei in 079efab
- fix(keypair): accept externally generated keys instead of panicking by @gouguolei in 012269d
- test(keypair): cover error paths and key material helpers by @gouguolei in 12c3e11
- docs(readme): replace old badge with golangci-lint by @gouguolei in 0517244
- docs(readme): replace old badge with golangci-lint by @gouguolei in 1487675
- test: Clean up redundant content and unused variables in the test code by @gouguolei in 372209d
- test(sm2): DER encoding error branch covering key formatting by @gouguolei in 6ad47b4
- refactor(keypair): Extract x509 Marshall function as a variable to support testing simulation by @gouguolei in e314c99
- refactor(crypto): Replace the ed25519 key serialization function with a local implementation by @gouguolei in 0769ea0
- refactor(rsa): Replace the standard library key serialization function with a custom implementation by @gouguolei in 2c9ad5a
- refactor(crypto/rsa): Simplify function signatures and clean up redundant code by @gouguolei in 68dad92
- docs(readme): Replace the golangci lit badge with the GitHub Actions status badge by @gouguolei in e6f8039
- docs(readme): Replace the image resource reference from remote URL to local assets path by @gouguolei in 19bffd5
v1.2.3 (2025-12-16)
✨ 新機能
- RSA 鍵ペアが操作に必要な鍵だけを保持できるようになりました:
RsaKeyPairにTypeフィールドとSetTypeメソッドを追加し、KeyType型とPublicKey、PrivateKey定数も新設しました。NewStdEncrypter、NewStdDecrypter、NewStdSigner、NewStdVerifierと対応するストリーム実装が鍵の種類で分岐するため、公開鍵だけを持つ鍵ペアでも暗号化と検証が、秘密鍵だけを持つ鍵ペアでも復号と署名ができます。公開鍵を署名側、秘密鍵を検証側にすることも可能です。Typeが空の場合は操作ごとに適切な側へフォールバックし(暗号化と検証はPublicKey、復号と署名はPrivateKey)、既定のパディングは鍵形式に従います(PKCS1はPKCS1v15、PKCS8は暗号化にOAEP、署名にPSS)。署名にOAEP、暗号化にPSSを渡すとUnsupportedPaddingSchemeErrorを返します。Go 標準ライブラリが片方向しか公開していない PSS エンコードと MGF1 を含め、公開鍵・秘密鍵の両方向とすべてのパディングの組み合わせをcrypto/internal/rsaに実装しました(by @gouguoyin in 12ffe48 eb81cbc 33ac684 749b690) Sm2KeyPairにSetModeを追加し、CipherOrderをSm2CipherModeに改名:暗号文の順序を指定する推奨方法がSetModeになり、SetOrderは既存の呼び出しがコンパイルできるよう薄いエイリアスとして残ります。型名の変更はCipherOrderを明示的に書いたコードにのみ影響し、引数名orderは全体でmodeに統一されて鍵の順序という意味と混同されなくなりました(by @gouguoyin in 858d8b8 3785a02 6d30805 56b6b15)
🔧 リファクタリング
Sm2KeyPairのLoadPublicKey、LoadPrivateKeyを削除:SM2 はファイルを自ら読み込む最後の鍵ペアで、呼び出し側はfs.Fileを渡す必要がありました。ファイルを自分で読み込んでSetPublicKey/SetPrivateKeyにバイト列を渡す形になり、RSA、Ed25519 と揃いました(by @gouguoyin in e4d6e3c)crypto/sm2をencrypt.go、decrypt.go、sign.go、verify.goに分割し、内部ヘルパーをEncryptWithPublicKey、DecryptWithPrivateKey、SignWithPrivateKey、VerifyWithPublicKeyに改名しました。どの鍵が必要かが呼び出し箇所で分かります。重複していた SM2 実装を削除し、補助関数を独立したファイルに分離、privフィールドはパッケージ内の命名に合わせてpriに改名しました(by @gouguoyin in 86819de 1602745 0dfd8ea c0a45e4 ccc968f f876923)- Ed25519 の解析済み鍵をキャッシュ:署名器と検証器は呼び出しごとに PEM を解析し、
crypto/keypairにある解析ロジックと重複していました。現在は一度だけ解析してキャッシュし、重複コードを削除、パッケージをed25519.go、sign.go、verify.goに分割しました(by @gouguoyin in 0ed7ca5) - RC4 フォールバック経路の不要な cipher 生成を削除:この分岐が生成した cipher は直ちに破棄されていました(by @gouguoyin in 9320875)
What's Changed (18)
- refactor(ed25519): Remove duplicate key parsing logic and use caching to improve performance by @gouguoyin in 0ed7ca5
- refactor(rc4): Delete the redundant code for creating cipher in fallback by @gouguoyin in 9320875
- chore(sm2): Remove redundant implementation and modularize the splitting function to independent files by @gouguoyin in 86819de
- refactor(sm2): priv -> pri by @gouguoyin in f876923
- feat(rsa): Provide signature generation and verification methods based on public and private keys by @gouguoyin in 749b690
- feat(keypair): Add key type definition to distinguish between public and private keys by @gouguoyin in 12ffe48
- feat(rsa): Add a Type field in the RsaKeyPair structure to specify the key type by @gouguoyin in eb81cbc
- feat(rsa): Add support for public key encryption and private key decryption by @gouguoyin in 33ac684
- refactor(sm2): Remove the CipherOrder type definition and replace it with a string constant by @gouguoyin in 3785a02
- refactor(sm2): Delete the 'LoadPublicKey' and 'LoadPrivateKey' methods by @gouguoyin in e4d6e3c
- refactor(sm2): Decrypt -> DecryptWithPrivateKey by @gouguoyin in 1602745
- refactor(sm2): Encrypt -> EncryptWithPublicKey by @gouguoyin in 0dfd8ea
- refactor(sm2): Sign -> SignWithPrivateKey by @gouguoyin in c0a45e4
- refactor(sm2): Verify -> VerifyWithPublicKey by @gouguoyin in ccc968f
- refactor(sm2): Change the function parameter name from 'order' to 'mode' by @gouguoyin in 6d30805
- feat(crypto): Add
SetModemethod to replace the existingSetOrdermethod by @gouguoyin in 858d8b8 - refactor(sm2): Rename the Order parameter to Mode by @gouguoyin in 56b6b15
- docs(utils): Update Int2Bytes function comments by @gouguoyin in 3d22896
v1.2.2 (2025-12-08)
✨ 新機能
- チェーン API に SM2 の署名と検証を追加:
Signer.BySm2とVerifier.BySm2を追加し、標準処理とストリーム処理の両方で利用できます。SM2 が RSA、Ed25519 と同じように、同じチェーン上で秘密鍵による署名と公開鍵による検証を行えます。Sm2KeyPair.SetUIDは ZA の計算に混ぜるユーザー識別子を設定し、未設定時は1234567812345678のままです。検証時に署名が空の場合は曲線演算に入る前にEmptySignatureErrorを返します(by @gouguoyin in b72066e 0382cd6 39d00c3) - RSA のパディング方式を選択可能に:
RsaPaddingScheme型がPKCS1v15、OAEP、PSSを提供し、SetPaddingで指定します。PKCS1v15は暗号化と署名の両方に、OAEPは暗号化のみでSetHashによるハッシュ指定が必要、PSSは署名のみに使えます。未指定の場合は鍵形式に従い、PKCS1の鍵はPKCS1v15、PKCS8の鍵はOAEPにフォールバックします。未対応の組み合わせは標準ライブラリの曖昧なエラーではなくUnsupportedPaddingSchemeErrorを返します(by @gouguoyin in d1734dc b4173be d08e5fc) - 鍵と署名のエラー型を細分化:
EmptyPrivateKeyError、EmptyFormatError、UnsupportedKeyFormatError、EmptyPaddingError、UnsupportedPaddingSchemeError、EmptySignatureErrorが単一の包括的なエラーを置き換え、鍵の欠落と鍵の破損を区別できるようになりました(by @gouguoyin in 856dd51)
🐛 修正
- 秘密鍵が PKCS#8 形式のときに PKCS#1 v1.5 の暗号文を復号できない問題を修正(#39):
FormatがPKCS8でパディングを明示しない場合、復号は OAEP にフォールバックしていたため、JSEncrypt や PHP のopenssl_*が既定のパディングで生成した暗号文はcrypto/rsa: decryption errorになりました。同じ暗号文を PHP 自身は復号できていました。現在はSetPaddingでパディングを指定でき、報告で使われた鍵ペアは回帰テストとして残しています(by @gouguoyin in 27c69f6) - RSA 検証の冗長な署名長チェックを削除:このチェックは
rsa.Verify*が検証する前に他ライブラリの正当な署名を拒否していました。標準ライブラリは不正な長さの署名に対して明確なエラーを返します(by @gouguoyin in faa99bb)
⚡ パフォーマンス
- モールスのエンコード・デコードで結果返却時のコピーを 1 回削減:
[]byte(builder.String())をutils.String2Bytesに置き換え、builderのバッファを再利用して余分なコピーをなくしました。出力自体が支配的な大きめのデータで効果があります(by @gouguoyin in 10d2eb0)
🔧 リファクタリング
- 鍵形式と暗号文順序の型をアルゴリズム別に改名:
KeyFormatをRsaKeyFormat、CipherOrderをSm2CipherOrderに変更し、すべてのアルゴリズムに適用されるかのような汎用的な名前をなくしました。NoSignatureErrorはEmptySignatureError、UnsupportedPemTypeErrorはUnsupportedKeyFormatError、Ed25519KeyPair.SignはSignatureになりました(by @gouguoyin in 37d5a1a ac77cf7 6135756 8a6ea39) - RSA の暗号化・復号・署名・検証の経路を書き直し:各操作は暗号化器、復号器、署名器、検証器の生成時にパディングを一度だけ決定して分岐するため、
PSSを暗号化に使う指定やOAEPのハッシュ不足はストリーム処理の途中ではなく生成時に報告されます(by @gouguoyin in d08e5fc) - ストリーム復号器のフィールド名を変更:
decryptedをbuffer、posをpositionに変更し、3DES、AES、Blowfish、DES、Tea、XTea、Twofish、SM4、Salsa20 に適用しました。あわせて 3DES ストリーム復号器の入力分割処理を簡素化しています(by @gouguoyin in 114d3be efefe59 e66e508 ba303e7 4d93579 e0b9f3b 5f311b4 426506a f375496 ce101f1) - Ed25519 の
StdSigner、StdVerifierが鍵ペアを値で保持:ポインタではなく値で保持するため、生成後に外部で鍵ペアを変更しても実行中の操作に影響しません。あわせて Ed25519 のエラー型を簡素化しました(by @gouguoyin in b5cd502 225b70f) mock、utilsをinternalに移動:テスト補助パッケージとゼロコピーのヘルパーはモジュール外部からインポートできなくなり、SM4 の実装はcrypto/internal/sm4に移りました(by @gouguoyin in ef82486 fe841a7)- 内部の
sm2curveパッケージをsm2に改名し、stdAsn1エイリアスを他のファイルで使われているencodingAsn1に統一しました(by @gouguoyin in 14e9818 cf69603) - テストを簡素化:
internal/mockのmock.Fileがテストごとに実装していた reader モックを置き換え、すべてのテストで開いたファイルを閉じるようにし、中国語のコメントを英語に統一しました(by @gouguoyin in 6b021d7 3ea3710 bd8b1b3 7fb2ddc 9a4b693 2cab5e7 bbc4123 ee77460)
📝 ドキュメント
- 鍵ペアパッケージのドキュメントと RSA の使い方を更新し、新しいパディング方式と鍵形式の型について補足しました(by @gouguoyin in dafc7cf b765056 399de93)
What's Changed (38)
- refactor(sm2curve): ParseDerPublicKey -> ParseBitStringPublicKey, ParseDerPrivateKey -> ParseBitStringPrivateKey by @gouguoyin in faac61c 81224c4
- refactor(internal): Move
mockandutilspackages tointernalby @gouguoyin in ef82486 - refactor(sm2curve): stdAsn1 -> encodingAsn1 by @gouguoyin in cf69603
- docs: Remove document comments for package by @gouguoyin in 43a793b
- test(coding): Change Chinese annotations to English by @gouguoyin in ee77460
- refactor(crypto/3des): Optimize the data processing logic of the streaming decryptor by @gouguoyin in ce101f1
- refactor: decrypted -> buffer, pos -> position in AES, Blowfish, DES, Tea, XTea, Twofish, SM4 and Salsa20 by @gouguoyin in 114d3be efefe59 e66e508 ba303e7 4d93579 e0b9f3b 5f311b4 426506a f375496
- refactor(ed25519): Modify the keypair field in StdSigner and StdVerifier to a value type instead of a pointer type by @gouguoyin in b5cd502
- refactor(ed25519): Simplify error types and optimize error message formats by @gouguoyin in 225b70f
- chore(crypto): NoSignatureError -> EmptySignatureError by @gouguoyin in 6135756
- fix(rsa): Remove redundant signature length check by @gouguoyin in faa99bb
- fix(rsa): Fix PKCS8 format key decryption failure (issue #39) by @gouguoyin in 27c69f6
- refactor(crypto): Sign -> Signature, UnsupportedPemTypeError -> UnsupportedKeyFormatError by @gouguoyin in 8a6ea39
- feat(crypto): Add multiple types of key and signature related errors by @gouguoyin in 856dd51
- feat(crypto): Introduce PaddingScheme type to support multiple RSA filling schemes by @gouguoyin in d1734dc
- feat(rsa): Add the SetPadding method by @gouguoyin in b4173be
- refactor(rsa): Refactoring RSA encryption, decryption, signature verification logic by @gouguoyin in d08e5fc
- feat(sm2curve): Implement SM2 algorithm signature and verification function by @gouguoyin in 0382cd6
- feat(sm2): Add SetUID method by @gouguoyin in 39d00c3
- refactor(crypto/sm2): Remove unused error types by @gouguoyin in 7bc33cd
- feat(crypto): Add SM2 signature and verification function by @gouguoyin in b72066e
- refactor(sm2): Remove redundant auxiliary functions and dependencies by @gouguoyin in bc5962c
- docs(keypair): Update the documentation for the key pair package by @gouguoyin in dafc7cf
- chore(rsa): Move the RSA key format and padding scheme type to the
rsa.gofile by @gouguoyin in 88ba1d6 - chore(sm2): Move the SM2 cipher order from
keypair.gotosm2.gofile by @gouguoyin in ac77cf7 - chore(test): KeyFormat -> RsaKeyFormat by @gouguoyin in 37d5a1a
- refactor(sm2): Rename the sm2curve package to sm2 and update related references by @gouguoyin in 14e9818
- refactor: Modify the cipher field type of the encryption and decryption structures in 3DES, AES, Blowfish, ChaCha20, ChaCha20-Poly1305, DES, Salsa20, Tea, XTea, Twofish and SM4 by @gouguoyin in d7d72be af560ef 582d5d8 38587f9 5b780d4 4c87f81 b0f2e45 ec29312 8435966 1b2be97 ab4ee6d
- test(sm2): []byte{} -> {} by @gouguoyin in 48834cc
- refactor(sm4): Migration of SM4 implementation from crypto/sm4/core.go to crypto/internal/sm4/sm4.go by @gouguoyin in fe841a7
- refactor(morse): Optimize the conversion method from string to byte slice by @gouguoyin in 10d2eb0
- test(coding): Simplify code using mock.File by @gouguoyin in 6b021d7
- test(crypto): Simplify code using mock.File by @gouguoyin in 3ea3710
- test(hash): Simplify code using mock.File by @gouguoyin in bd8b1b3
- test(sm2): Simplify code using mock.File by @gouguoyin in 7fb2ddc
- test: Add defer file.Close() to all test functions to avoid resource leakage by @gouguoyin in 9a4b693 2cab5e7 bbc4123
- docs(crypto): Update RSA key pair document comments by @gouguoyin in b765056
- docs(rsa): Update RSA key pair usage instructions by @gouguoyin in 399de93
v1.2.1 (2025-11-24)
✨ 新機能
Sm2非対称楕円曲線暗号化アルゴリズムにBIT_STRING形式キーの直接解析サポートを追加
🐛 修正
Sm2非対称楕円曲線暗号化アルゴリズムのwNAFアルゴリズムエラーによる一部の復号化失敗のバグを修正
⚡ パフォーマンス
Sm2非対称楕円曲線暗号化アルゴリズムの曲線フィールド要素演算実装を最適化
🔧 リファクタリング
- テストループ構文を簡素化、
forループからrangeループに変更
What's Changed (12)
- refactor(sm2curve): pointFelem -> pointField by @gouguoyin in eb6878e
- test(sm2): Change the declaration method of empty byte slices from literal to var declaration by @gouguoyin in 38a86c8
- style(sm2curve): Add necessary comments by @gouguoyin in 27497c7
- Potential fix for code scanning alert no. 1: Workflow does not contain permissions (#33) by kuafuRace in 9bab6c9
- Add direct parsing of hexadecimal key pairs for SM2 (#32) by @WebChang in a4509b6
- Fix the wNAF algorithm (#36) by @WebChang in 73911e8
- fix(crypto): Introduce a rewritable parseDerPrivatKeyFunc variable to support test simulation by @gouguoyin in d61fe04
- test(sm2): Improve unit testing coverage to 100% by @gouguoyin in 7b2ddf3
- chore(version): Update version number to 1.2.1 by @gouguoyin in 31d1ee7
- Add issue unit test (#38) by @WebChang in b91161c
- fix(sm2curve): Fix SM2 curve domain element subtraction and borrowing processing by @gouguoyin in 1164b55
- fix(sm2): Add issue #34 unit test by @gouguoyin in b86b4dd
v1.2.0 (2025-11-11)
✨ 新機能
RSAKeyPair構造体にFormatPublicKeyおよびFormatPrivateKeyメソッドを追加、base64エンコードされたder形式のRSA公開鍵と秘密鍵をpem形式にフォーマットEd25519KeyPair構造体にFormatPublicKeyおよびFormatPrivateKeyメソッドを追加、base64エンコードされたder形式のEd25519公開鍵と秘密鍵をpem形式にフォーマットRSAKeyPair構造体にCompressPublicKeyおよびCompressPrivateKeyメソッドを追加、pem形式のRSA公開鍵と秘密鍵をbase64エンコードされたder形式に圧縮Ed25519KeyPair構造体にCompressPublicKeyおよびCompressPrivateKeyメソッドを追加、pem形式のEd25519公開鍵と秘密鍵をbase64エンコードされたder形式に圧縮Sm2非対称楕円曲線暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含む)
⚡ パフォーマンス
- エンコーダーとデコーダーのパフォーマンスを最適化、読み取りバッファを再利用し、メモリ割り当てとコピーを削減
🔧 リファクタリング
RSAKeyPair構造体のLoadPublicKeyおよびLoadPrivateKeyメソッドを削除Ed25519KeyPair構造体のLoadPublicKeyおよびLoadPrivateKeyメソッドを削除RSAKeyPair構造体のGenKeyPair、SetPublicKey、SetPrivateKeyメソッドを返り値なしからerrorを返すように変更Ed25519KeyPair構造体のGenKeyPair、SetPublicKey、SetPrivateKeyメソッドを返り値なしからerrorを返すように変更
What's Changed (25)
- chore(dongle): Update package meta and version number by @gouguoyin in ab46cdb
- feat(mock): Add
Error WriteAfterNstruct, which supports returning an error after a specified number of writes by @gouguoyin in a92350f - test(style): Unify unit test case Name by @gouguoyin in fda8e09
- fix(cipher): Change the return value of empty input from
srcto[]byte{}by @gouguoyin in 81d8e29 - feat(sm2curve): Implement SM2-P-256 elliptic curve and ASN.1 encoding and decoding for sm2 by @gouguoyin in 8120c6b
- perf(base32): Optimize the performance of streaming codecs by @gouguoyin in df8bc9f
- perf(base45):Optimize the performance of base45 encoding and decoding by @gouguoyin in 15669d5
- refactor(base58): Optimize the implementation of stream encoders and decoders by @gouguoyin in 70b7b7b
- refactor(base62): Optimize the implementation of stream encoders and decoders by @gouguoyin in 2de952d
- perf(base64): Optimize the implementation of stream encoders and decoders by @gouguoyin in 94575a1
- refactor(base85): Optimize the implementation of stream encoders and decoders by @gouguoyin in 5c03d1a
- perf(base91): Optimize encoding and decoding performance by @gouguoyin in bcff90c
- perf(base100): Optimize the implementation of stream encoders and decoders by @gouguoyin in 058877c
- refactor(morse): Optimize the buffer usage of streaming decoders by @gouguoyin in a52a536
- feat(unicode): Optimize the buffer usage of streaming decoders by @gouguoyin in dd27319
- feat(crypto): Add FormatPublicKey,FormatPrivateKey, CompressPublicKey, CompressPrivateKey methods by @gouguoyin in e947625
- feat(crypto): Add EmptyPublicKeyError and EmptyPrivateKeyError by @gouguoyin in c844db5
- refactor(keypair): Add CipherOrder type to control the order of SM2 ciphertext components by @gouguoyin in e3d8df9
- feat(sm2): Add support for SM2 asymmetric elliptic curve encryption algorithm by @gouguoyin in dfa2a45
- perf(md2): Optimize the performance of MD2 hash algorithm by @gouguoyin in 380718a
- perf(sm3): Optimize the performance of SM3 hash algorithm by @gouguoyin in 9b1e3ed
- docs(readme): Add playground link url by @gouguoyin in c4fac75
- docs: Update the annotation explanation in AES symmetric encryption algorithm by @gouguoyin in 4adf429
- refactor(sm2curve): Refactor the SM2 curve implementation to improve performance and maintainability by @gouguoyin in 10eefe2
- refactor(crypto): MarshalPKCS8 -> MarshalPKCS8PrivateKey, MarshalSPKI ->MarshalSPKIPublicKey by @gouguoyin in ef63d93
v1.1.8 (2025-11-05)
✨ 新機能
Unicodeエンコード/デコードサポートを追加(標準処理とストリーム処理を含む)- 対称ブロック暗号化アルゴリズムに
TBCパディングモードサポートを追加
🐛 修正
*RsaKeyPair.formatPublicKeyおよび*RsaKeyPair.formatPrivateKeyによる鍵のフォーマット失敗のバグを修正*Ed25519KeyPair.formatPublicKeyおよび*Ed25519KeyPair.formatPrivateKeyによる鍵のフォーマット失敗のバグを修正- 復号化時にエンコードされた暗号文のデコードが失敗した場合、エラーを取得できないバグを修正
🔧 リファクタリング
- 対称ブロック暗号化アルゴリズムのデフォルトパディングモードを
PKCS7からNoに変更
What's Changed (36)
- chore(version): Update version number to
1.1.8by @gouguoyin in 3bfd036 - feat(crypto): Add TBC padding mode support by @gouguoyin in 304629d
- feat(unicode): Add
Unicodeencoding and decoding support by @gouguoyin in d174cd8 - ci(test): Add support for Windows testing environment by @gouguoyin in da9ec1e
- fix(hash): Add checks for h.Error by @gouguoyin in c044908
- fix(decoder): Add checks for d.Error by @gouguoyin in 18041a3
- fix(encoder): Add checks for e.Error by @gouguoyin in f97a481
- feat(unicode): Add
Unicodeencoding/decoding support by @gouguoyin in 8e1c38c - feat(crypto): Add custom nonce length support for
GCMmode by @gouguoyin in 5cdaac8 - fix(signer): Add checks for s.Error by @gouguoyin in f0f2bc2
- fix(crypto): Fix signature decoding error handling by @gouguoyin in 4107901
- fix(crypto): Fix ciphertext decoding error handling by @gouguoyin in 763afd8
- refactor(crypto): Change the default padding mode from
PKCS7toNoby @gouguoyin in 00bd32b - feat(crypto/cipher): Optimize the block size check in CBC mode by @gouguoyin in 781f292
- refactor(cipher): Simplify the error handling using switch by @gouguoyin in a0abcf5
- refactor(cipher): InvalidSrcError -> InvalidPlaintextError by @gouguoyin in 2677ffc
- test(des): Remove redundant decryption error test cases by @gouguoyin in 72c39cd
- test(aes): Remove redundant decryption error test cases by @gouguoyin in 36807d5
- test(sm4): Remove padding settings by @gouguoyin in 7cdf2b5
- feat(crypto): Remove padding setting by @gouguoyin in bac1c2a
- fix(xtea): Fix the panic issue in the stream encryption by @gouguoyin in 94596c4
- test(crypto): Update error type assertion by @gouguoyin in 15014ea
- fix(aes): Remove unnecessary comments by @gouguoyin in 37d2aeb
- fix(crypto): Update 3DES decryption error type assertion by @gouguoyin in 1d6ff35
- feat(crypto): Add empty source data check by @gouguoyin in ba919b3
- feat(crypto): Add EmptySrcError type by @gouguoyin in 3dd14a4
- refactor(ed25519): Refactor key formatting method and adding compression method by @gouguoyin in 5be56c1
- refactor(rsa): Refactor RSA key formatting method and adding compression method by @gouguoyin in 7fcd12c
- feat(keypair): Add formatKeyBody function by @gouguoyin in 0893b5d
- refactor(ed25519): Remove non essential comments by @gouguoyin in 734a5f2
- test(ed25519): Add edge testing for
StreamSigner.Writemethod by @gouguoyin in db4dd67 - refactor(crypto): Delete the Error field and instead handle errors through return values by @gouguoyin in b5d9349
- refactor(rsa): Change the return value of the
GenKeyPairmethod from*RsaKeyPairto error by @gouguoyin in e384f4f - chore(crypto): Simplify code by @gouguoyin in 40e077a
- chore(ed25519): Improve key generation and parsing error handling by @gouguoyin in 20893dc
- chore(rsa): Improve key generation and parsing error handling by @gouguoyin in ab5e7a8
v1.1.7 (2025-10-20)
✨ 新機能
sm4中国国家標準ブロック暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含み、異なるブロックモードとパディングモードをサポート)
🐛 修正
- 非対称デジタル署名アルゴリズムの検証エラーのバグを修正 #30
- ストリーム処理ロジックを最適化し、
reader位置リセットサポートを追加してデータソースの先頭から読み取りを保証し、以前の読み取り操作による位置オフセット問題を回避し、ストリーム操作の完全性と正確性を保証
🔧 リファクタリング
crypto/cipher/block.goのnewXXXEncrypterとnewXXXDecrypterシリーズのプライベートメソッドを公開メソッドNewXXXEncrypterとNewXXXDecrypterに変更crypto/cipher/padding.goのnewXXXPaddingとnewXXXUnPaddingシリーズのプライベートメソッドを公開メソッドNewXXXPaddingとNewXXXUnPaddingに変更
What's Changed (38)
- chore: Add support for the
io.Seekerinterface to reset the reading position by @gouguoyin in 07a19a9 - refactor(decoder): ff -> f by @gouguoyin in ae38f87
- refactor(test): Unify package import order by @gouguoyin in 36064e0
- docs(github/crypto): Add a period to the note on the encryption method by @gouguoyin in c4af6bd
- feat(crypto): Add support for the SM4 block cipher algorithm by @gouguoyin in 537b615
- chore(crypto/cipher): Remove the comment regarding the default number of rounds in TEA encryption by @gouguoyin in 8b72470
- feat(cipher): Unify function naming convention, newXXX -> NewXXX by @gouguoyin in cff507c
- build(dongle): Update the version number to v1.1.7 by @gouguoyin in 22f0f85
- docs(crypto/cipher): Update the annotation of the padding function by @gouguoyin in f90f6a7
- chore(crypto/cipher): Unify error return variable names and remove redundant comments by @gouguoyin in 6e9db0f
- fix(coding): Optimize the return value when there is an error by @gouguoyin in b581d3b
- chore(crypto): Add initialization error checking by @gouguoyin in 01d6ec7
- test(aes): Delete unnecessary test cases by @gouguoyin in af904d0
- test(des): Delete unnecessary test cases by @gouguoyin in b3f67f6
- test(xtea): Delete unnecessary test cases by @gouguoyin in ba26567
- fix(cipher): Remove duplicate nil block checking logic by @gouguoyin in f13aa33
- chore(crypto/cipher): Add CBC/ECB mode padding processing comments by @gouguoyin in 1205cab
- chore(crypto/cipher): Remove the early return logic when the extra data is empty by @gouguoyin in b66ba65
- test(cipher): Remove duplicate decryption test cases by @gouguoyin in b534394
- test(crypto): Remove test case for invalid cipher by @gouguoyin in d5b5849
- chore(coding): Add comments to Encoder and Decoder structures by @gouguoyin in 57ae7a4
- refactor(crypto):
UnsupportedModeError->UnsupportedBlockModeErrorby @gouguoyin in b6e71b1 - docs(hash): Update package comments by @gouguoyin in 3eb6ce7
- docs(cipher): Add comments by @gouguoyin in 4ec008c
- refactor(cipher): Remove unnecessary return parameters by @gouguoyin in 4e52d83
- fix(cipher): Improve encryption and decryption error handling logic by @gouguoyin in 0d5947a
- feat(crypto): Add UnsupportedBlockModeError and UnsupportedPaddingModeError by @gouguoyin in 2cc0511
- feat(cipher): Optimize zero padding logic by @gouguoyin in cbb4c56
- docs(keypair): Add comments by @gouguoyin in 2122e07
- docs: Update the description of padding mode and hash algorithms in the README by @gouguoyin in 3d0dbb7
- refactor(cipher): Refactor the padding and unpadding methods as receiver methods by @gouguoyin in 3d73c89
- chore(hash): Add comments by @gouguoyin in fe9ba67
- chore(cipher): Unified error return format by @gouguoyin in 063b25c
- fix(rsa): Fix variable reference errors in signature verification logic,
kp.Sign->v.signby @gouguoyin in e78cd47 - test: Add issue #30 unit test cases by @gouguoyin in 2cb142a
- feat(crypto): Add verify status field to enhance signature verification logic by @gouguoyin in c7a76bd
- refactor(utils): []byte("") -> []byte{} by @gouguoyin in 7e378cd
- vm-os: [ubuntu-latest, macos-latest, windows-latest] by kuafuRace in 340283c
v1.1.6 (2025-10-12)
✨ 新機能
tea暗号化アルゴリズムを最適化し、異なるブロックモードとパディングモードをサポートxtea暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含む)
🔧 リファクタリング
io.CopyBufferを使用してストリーム処理ロジックを簡素化
What's Changed (26)
- docs(readme): Update the import path in README.cn.md by @gouguoyin in dbe8da4
- refactor: Rename the
utilpackage toutilsby @gouguoyin in 9c4122e - refactor(cipher): decrypted -> paddedDst by @gouguoyin in 4537c96
- refactor(mock): Unify the naming of receivers in error file simulation by @gouguoyin in def9c0a
- refactor(mock): Move package comment from
file.gotodoc.goby @gouguoyin in 0a86b4a - refactor(utils): Add package comment in
doc.goby @gouguoyin in d625676 - style: Add necessary notes by @gouguoyin in 35ed473
- docs: Add package comments by @gouguoyin in 08ddc95
- chore(encoder):Optimize error handling logic by @gouguoyin in 6b723b5
- chore(coding): Unify the naming of error handling variables and optimize the reading logic by @gouguoyin in 3d16e0f
- chore(crypto): Unify the naming of error handling variables and optimize the reading logic by @gouguoyin in ca35d52
- test: Add test case for issue #28 by @gouguoyin in b87981c
- build: Update version number to
1.1.6by @gouguoyin in 4a16814 - refactor(hash): Use
io.CopyBufferto replace manual reading of the buffer, simplifying the implementation ofstreamandhmacmethods by @gouguoyin in cf399b5 - fix(blowfish): Fix the return value counting logic after encrypted data is written by @gouguoyin in 70ea1f7
- refactor(ed25519): Remove redundant random number generator by @gouguoyin in 6c974f4
- fix(rsa): Optimize RSA key parsing logic and fix return value handling by @gouguoyin in 6ca625c
- feat(crypto): Use
io.CopyBufferto improve the performance and efficiency of stream processing readability and fixing potential read error issues by @gouguoyin in b1d4247 - refactor(decoder):Simplify streaming process with
io.CopyBufferby @gouguoyin in bc1c6ab - refactor(encoder):Simplify streaming process with
io.CopyBufferby @gouguoyin in 730c151 - feat(crypto/tea): Optimize the tea algorithm to support different blocking and padding modes by @gouguoyin in 817e4c5
- feat(crypto/xtea): Add support for
xteaalgorithm by @gouguoyin in 6cc0c01 - test(3des): Remove useless and erroneous tests by @gouguoyin in 2df56d8
- test: Replace the existing custom errorCloser with CloseErrorWriteCloser from the mock library by @gouguoyin in e70157b
- feat(cipher): Update the implementation of the TEA encryption algorithm to support block mode by @gouguoyin in b90d008
- style: Unify the function annotation style and revise some algorithm descriptions by @gouguoyin in 9509d43
v1.1.5 (2025-10-01)
🐛 修正
- パディングが不要なブロックモード(CFB/OFB/CTR/GCM など)で対称暗号化アルゴリズムがパディングを実行した際の暗号化/復号化エラーのバグを修正
What's Changed (6)
- build(dongle): Updated version number to 1.1.5 by @gouguoyin in 8e1a462
- test(issue): Add issue test file by @gouguoyin in d77ad8c
- refactor(crypto): Unify package grouping import rule by @gouguoyin in 17ff89c
- test(aes): Remove t.Skip test cases by @gouguoyin in 82f450f
- refactor(coding): Unify package grouping import rule by @gouguoyin in 833c1c2
- refactor(cipher): Optimize the logical structure of encryption and decryption #29 by @gouguoyin in a598772
v1.1.4 (2025-09-23)
✨ 新機能
twofish暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含む)
🔧 リファクタリング
- グローバルデフォルトインスタンス使用時のプロパティ汚染を防ぐため、メソッドレシーバーをポインタから値に変更、呼び出し側
APIへの影響はなし
What's Changed (5)
- build(dongle.go): Update the version number to v1.1.4 by @gouguoyin in 3abadc6
- refactor: Change the receiver of the method from a pointer type to a value type by @gouguoyin in 9b9b104
- docs(chacha20): Add package comments``` by @gouguoyin in 3a66727
- docs(chacha20poly1305): Add package comments by @gouguoyin in 25b9c56
- feat(crypto): Add support for the Twofish encryption algorithm by @gouguoyin in fd78849
v1.1.3 (2025-09-15)
✨ 新機能
testify依存関係をv1.11.1に更新
🐛 修正
3DES対称暗号化アルゴリズムの16バイトキー互換性を最適化DES対称暗号化アルゴリズムのサポートされていないGCMモード検証を最適化3DES対称暗号化アルゴリズムのサポートされていないGCMモード検証を最適化Blowfish対称暗号化アルゴリズムのサポートされていないGCMモード検証を最適化
🔧 リファクタリング
Salsa20暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含む)
What's Changed (21)
- chore(deps): Update the testify dependency to
v1.11.1by @gouguoyin in 6644d40 - chore: Update dongle to
v1.1.3by @gouguoyin in efa7ffd - perf(hash/md2): []byte{} -> var data []byte by @gouguoyin in e4c4362
- refactor(hash): Unify import package order by @gouguoyin in 57a68fa
- perf(test): []byte{} -> var data []byte by @gouguoyin in f2c7321
- feat(crypto): Add support for the Salsa20 encryption algorithm by @gouguoyin in 8df1550
- fix(crypto/des): Add a error check for unsupported
GCMmode by @gouguoyin in 10c123d - fix(crypto/blowfish): Add an error check for unsupported
GCMmode by @gouguoyin in 7f343cb - fix(crypto/3des): Add an error check for unsupported
GCMmode by @gouguoyin in 6c12f0c - fix(crypto/des): Add an error check for unsupported
GCMmode by @gouguoyin in 895547e - refactor(crypto/aes): Optimize AES encryption and decryption operations by @gouguoyin in 436ae5e
- test(3des): Create alone test files for each block cipher mode by @gouguoyin in ae47981
- test(aes): Create alone test files for each block cipher mode by @gouguoyin in 4c1c349
- test(blowfish): Create alone test files for each block cipher mode by @gouguoyin in 31cfeab
- test(des): Create alone test files for each block cipher mode by @gouguoyin in 171eb70
- fix(crypto/chacha20): Unify import package order by @gouguoyin in d8c9242
- chore(crypto/chacha20loly1305): Unify import package order by @gouguoyin in 718779f
- test(rc4): Modify the test case description by @gouguoyin in f3cad2b
- test(crypto): Unify import package order by @gouguoyin in 8a8361a
- perf(benchmarks): init -> initBenchData by @gouguoyin in 88e5a2f
- feat(crypto): Add documentation comments for the package by @gouguoyin in 9fbddeb
v1.1.2 (2025-09-08)
✨ 新機能
- エンコード/デコードが
coding.BufferSizeグローバル変数によるファイルストリームバッファサイズのカスタマイズをサポート - 暗号化/復号化が
crypto.BufferSizeグローバル変数によるファイルストリームバッファサイズのカスタマイズをサポート - Hash/Hmacアルゴリズムが
hash.BufferSizeグローバル変数によるファイルストリームバッファサイズのカスタマイズをサポート Blake2bハッシュアルゴリズムサポートを追加(blake2b-256、blake2b-384、blake2b-512を含む)Blake2sハッシュアルゴリズムサポートを追加(blake2s-128、blake2s-256を含む)ChaCha20暗号化アルゴリズムサポートを追加ChaCha20Poly1305暗号化アルゴリズムサポートを追加
What's Changed (24)
- fix(crypto): Remove redundant code by @gouguoyin in 05ec861
- feat(crypto): Add support for the
ChaCha20encryption algorithm by @gouguoyin in cdff998 - docs: Update usage examples by @gouguoyin in 6710e8f
- refactor(coding): Add BufferSize global variable to define the buffer size for stream processing by @gouguoyin in 2fecf80
- refactor(hash): Add BufferSize global variable to define the buffer size for stream processing by @gouguoyin in 870c557
- refactor(crypto): Add BufferSize global variable to define the buffer size for stream processing by @gouguoyin in 768d89d
- refactor(hash): hash -> hashFunc by @gouguoyin in f68a56c
- refactor(hash): Optimize error messages by @gouguoyin in 1d4d33b
- docs(README): Add digital signature and verification example by @gouguoyin in 762ba1c
- docs: Remove the digital signature and verification example by @gouguoyin in 2eeccf2
- docs(README): Update RSA signature verification example by @gouguoyin in 49e802b
- refactor(hash): Remove the redundant variable totalBytes by @gouguoyin in e14030d
- feat(hash): Add support for the
BLAKE2bhash algorithm by @gouguoyin in 0683cc0 - feat(hash): Add support for the
BLAKE2shash algorithm by @gouguoyin in f5870d7 - test(hash): Unified import of grouping styles by @gouguoyin in 74c2c4a
- test(coding): Unified import of grouping styles by @gouguoyin in 6bb8efd
- test(crypto): Unified import of grouping styles by @gouguoyin in 63e3e81
- test(keypair): Unified import of grouping styles by @gouguoyin in 72be367
- test(cipher): Unified import of grouping styles by @gouguoyin in 6961d3f
- test(cipher): blockCipher.Aad -> blockCipher.AAD by @gouguoyin in 04848cc
- feat(crypto): Add support for
ChaCha20-Poly1305encryption algorithm by @gouguoyin in 8e3b5c3 - docs(README):
hex string->hex-encoded string,base64 string->base64-encoded stringby @gouguoyin in 2c78e49 - docs(README): Use the import block to uniformly import multiple packages by @gouguoyin in 7d8e358
- build: Update the version number to 1.1.2 by @gouguoyin in 80b23e0
v1.1.1 (2025-09-01)
✨ 新機能
- エンコード/デコード、暗号化/復号化、Hash/Hmac、署名/検証の真のストリーム処理をサポート
ED25519デジタル署名と検証サポートを追加SM3ハッシュアルゴリズムサポートを追加coding/morse/morse.goにスペース、句読点、特殊文字のサポートを追加
⚡ パフォーマンス
- 入力データが空の場合、後続処理を実行せずに直接空データを返す
🔧 リファクタリング
- 対称暗号化アルゴリズムを
ByXXX(cipher.XXXCipher)からByXXX(*cipher.XXXCipher)に変更 - ユーティリティパッケージ名を
utilsからutilに変更 hash.Hashインターフェースのエラーをモックするためのmock/hash.goを追加
What's Changed (42)
- docs(readme): Update RSA encryption and decryption example by @gouguoyin in 4094aac
- refactor: Rename utils package to util by @gouguoyin in 9242991
- feat(hash): Add support for
SM3hash algorithm by @gouguoyin in 3f6e407 - refactor(crypto/3des): Refactor 3DES encryptor and decryptor by @gouguoyin in 4ed070e
- refactor(crypto): Refactor AES encryptor and decryptor by @gouguoyin in 6a3dcf9
- refactor(crypto): Refactor DES encryptor and decryptor by @gouguoyin in 39193c7
- refactor(rc4): Change the parameter type of the ByRc4 method from
cipher.Rc4Cipherto*cipher.Rc4Cipherby @gouguoyin in 4bcba4e - refactor(tea):
cipher.TeaCipher->*cipher.TeaCipherby @gouguoyin in f90f82c - refactor(tea):
cipher.BlowfishCipher->*cipher.BlowfishCipherby @gouguoyin in af4db9d - refactor(crypto/cipher):Rename the
paddingfunction and remove the internaldispatcherby @gouguoyin in e44f321 - feat(crypto): Add the blockCipher struct and encryption/decryption functionality by @gouguoyin in 0c93355
- refactor(crypto/cipher): Change the encryptor and decryptor methods to private by @gouguoyin in 4ab52bd
- refactor(cipher): Refactor the password encoder structure and optimize test cases by @gouguoyin in f904e13
- refactor(mock): data := []byte{} -> var data []byte by @gouguoyin in 40178d8
- refactor: Use
mock.NewFileinstead ofstrings.NewReaderandbytes.NewReaderby @gouguoyin in b77f6c3 - refactor: Use the
errors.Asfunction instead of type assertion by @gouguoyin in c4ddfd0 - feat: Add
FromFilemethod by @gouguoyin in a07314f - refactor: []byte{} -> var []byte by @gouguoyin in 01ebf5e
- test(crypto/cipher): Remove redundant comments by @gouguoyin in e0fb4d0
- test: TestErrorTypes -> TestRsaErrorTypes by @gouguoyin in cd0a48a
- refactor(crypto): triple_des -> tripleDes by @gouguoyin in e3add07
- feat(crypto): Add ED25519 signature and verification methods by @gouguoyin in 39f0ce3
- refactor(crypto): Update variable naming to use camelCase by @gouguoyin in 50d5d4b
- perf(crypto): Remove the error checking for the result of
hasher.Writeby @gouguoyin in 966bdd5 - refactor(mock): Added
mock/hash.goto simulate error conditions of thehash.Hashinterface by @gouguoyin in 4e38f79 - test(coding): Optimize code and add benchmark tests by @gouguoyin in ce64a33
- test(hash): Optimize code and add benchmark tests by @gouguoyin in a30f570
- feat: Implement true streaming encoding and decoding by @gouguoyin in 0fdc666
- feat: Implement true streaming hashing by @gouguoyin in 916d8f3
- refactor(mock): Improve the Sum method of ErrorHasher and add test cases by @gouguoyin in 913ef51
- feat(crypto): Refactor the ED25519 stream signature and verification logic to achieve true stream signature and verification by @gouguoyin in 704bdda
- fix(crypto): Optimize the logic of Close and ReadAll by @gouguoyin in fa1e139
- refactor(crypto): Refactor the Encrypter.stream method to implement true streaming encryption by @gouguoyin in 71ad312
- test(rc4): Optimize the test coverage for RC4 by @gouguoyin in 38b2928
- feat: Implement true streaming encryption and decryption by @gouguoyin in 961dc5d
- build: Update the version number to 1.1.1 by @gouguoyin in a2c746b
- feat(morse): Add support for spaces, punctuation marks, and special characters by @gouguoyin in 017497c
- fix(crypto/3des): Return null data when encrypting or decrypting null data by @gouguoyin in 3145828
- fix(crypto/aes): Return null data when encrypting or decrypting null data by @gouguoyin in f19243d
- fix(crypto/blowfish): Return null data when encrypting or decrypting null data by @gouguoyin in e9c1905
- fix(crypto/des): Return null data when encrypting or decrypting null data by @gouguoyin in 7ad600f
- test: Use
mock.NewFileinstead ofstrings.NewReaderandbytes.NewReaderby @gouguoyin in c70e218
v1.1.0 (2025-08-23)
⚠️ これは破壊的な更新バージョンです。慎重にアップグレードしてください。ただし、アップグレードを強く推奨します
✨ 新機能
ファイルストリームのエンコード/デコード、暗号化/復号化、Hash/Hmac、署名/検証サポートを追加ByBase32Hexエンコード/デコードメソッドを新規追加base32/base32Hexエンコードにカスタム文字セットサポートを追加base45エンコードにカスタム文字セットサポートを追加base58エンコードにカスタム文字セットサポートを追加base62エンコードにカスタム文字セットサポートを追加base64/base64Urlエンコードにカスタム文字セットサポートを追加
🔧 リファクタリング
BySafeURLエンコード/デコードメソッドを削除Sm3ハッシュアルゴリズム(hash)とメッセージ認証コードアルゴリズム(hmac)を削除ByBase64URLエンコード/デコードメソッドをByBase64Urlに名前変更- ハッシュアルゴリズム(
hash)呼び出し方式をdongle.Encrypt.ByXXX()からdongle.Hash.ByXXX()に変更 - メッセージ認証コードアルゴリズム(
hmac)呼び出し方式をdongle.Encrypt.ByHmacXXX()からdongle.Hash.WithKey().ByXXX()に変更 AES,DES,3DES,Blowfishなどの対称暗号化/復号化メソッドをリファクタリング、cipher.NewXXXCipher()で統一RSAなどの非対称暗号化/復号化メソッドをリファクタリング、keypair.NewXXXKeyPair()で統一
What's Changed (55)
- Update content by @gouguoyin in 41dbddf
- Unified error handling by @gouguoyin in 79209ec
- Update introduction by @gouguoyin in 839738a
- Update references link by @gouguoyin in 178ccbf
- build: Upgrade go and dependency library version by @gouguoyin in bd915fa
- chore: Delete unnecessary directories and files by @gouguoyin in 4050bc9
- feat(coding): Add streaming encoding and decoding for base32 by @gouguoyin in bd888e4
- feat(coding): Refactor encoding and decoding for base32, and added streaming support by @gouguoyin in 3658c88
- feat(coding): Refactor encoding and decoding for base45, and added streaming support by @gouguoyin in 4a9e5f1
- feat(coding): Refactor encoding and decoding for base58, and added streaming support by @gouguoyin in 94af864
- feat(coding): Refactor encoding and decoding for base62, and added streaming support by @gouguoyin in ec8cf47
- feat(coding): Refactor encoding and decoding for base64, and added streaming support by @gouguoyin in fab63f8
- feat(coding): Refactor encoding and decoding for base85, and added streaming support by @gouguoyin in 12b8686
- feat(coding): Refactor encoding and decoding for base91, and added streaming support by @gouguoyin in 6253df9
- feat(coding): Refactor encoding and decoding for base100, and added streaming support by @gouguoyin in 7938084
- feat(coding): Refactor encoding and decoding for hex, and added streaming support by @gouguoyin in 90421f9
- feat(coding): Refactor encoding and decoding for morse, and added streaming support by @gouguoyin in e556a27
- test(coding): Add unit tests and examples for Base32 encoding and decoding by @gouguoyin in 49e8824
- test(coding): Add unit tests and examples for Base45 encoding and decoding by @gouguoyin in 8bb6af4
- test(coding): Add unit tests and examples for Base58 encoding and decoding by @gouguoyin in 9acead1
- test(coding): Add unit tests and examples for Base62 encoding and decoding by @gouguoyin in 0e759d4
- test(coding): Add unit tests and examples for Base64 encoding and decoding by @gouguoyin in 56b939f
- test(coding): Add unit tests and examples for Base85 encoding and decoding by @gouguoyin in e3c40d3
- test(coding): Add unit tests and examples for Base91 encoding and decoding by @gouguoyin in 581084d
- test(coding): Add unit tests and examples for Base100 encoding and decoding by @gouguoyin in 8a649aa
- feat(coding): Add a universal decoder by @gouguoyin in 56e267d
- feat(coding): Add a universal encoder by @gouguoyin in df83e3d
- test(coding): Add Decoder unit test by @gouguoyin in c8cd146
- test(coding): Add Encoder unit test by @gouguoyin in 9ffeeb2
- test(coding): Add unit tests and examples for Hex encoding and decoding by @gouguoyin in 7f0ebed
- test(coding): Add unit tests and examples for Morse encoding and decoding by @gouguoyin in e090a75
- feat(utils): Add string and byte slice conversion tools by @gouguoyin in 3d8531a
- feat: Create a dongle package and initialize the basic structure by @gouguoyin in be20106
- test(mock): Add mock file implementation and related tests by @gouguoyin in 4966d26
- feat(hash): Reconstruct hash algorithm by @gouguoyin in a72d1b5
- feat(crypto): Reconstruct crypto algorithm by @gouguoyin in 935cb7f
- test: xxx_unit_test.go -> xxx_test.go by @gouguoyin in a015292
- feat: Add a Hasher instance by @gouguoyin in 421a980
- build: Update the dependency version in
go.modby @gouguoyin in 195b44c - docs: Add a Japanese README file by @gouguoyin in 64b7b5c
- build: Update import path by @gouguoyin in 290a5d2
- docs: Update the code coverage badge link in the README file by @gouguoyin in 918a4c7
- docs:HASH -> Hash, HMAC -> Hmac by @gouguoyin in bfe4ef9
- refactor: Unify import sequence by @gouguoyin in 1312eb8
- refactor(rsa): Reconstruct signature and verification by @gouguoyin in f5bda3f
- refactor(crypto): Support streaming decryption by @gouguoyin in a3fdee1
- docs(README): Update project documents and logo links by @gouguoyin in a7c712b
- ci: Update workflow configuration and code coverage branch by @gouguoyin in 1f09724
- ci: Update workflow configuration by @gouguoyin in 1956fbc
- ci: Update code coverage branch by @gouguoyin in dfb63f6
- test: Remove utils/converter_example_test.go by @gouguoyin in 17e9909
- ci: Update the testing workflow to include all directories by @gouguoyin in f2c8a46
- feat: Add version number constant by @gouguoyin in f6f6061
- docs(readme): Update the README file in multiple languages by @gouguoyin in 28993a4
- docs: Update the project introduction in the README file by @gouguoyin in eb8def1
v1.0.1 (2024-11-22)
✨ 新機能
base62カスタムエンコードテーブルをサポート
🐛 修正
AES-CBC-PKCS5暗号化復号化エラーのBugを修正
🔧 リファクタリング
- コード品質と組織構造を最適化
errors.goファイルを削除、エラー情報を各ファイルに移行- 単体テストフォーマットを統一
- 中文コメントを削除
What's Changed (22)
- Changed badge url by @gouguoyin in 5f1a726
- update by @gouguoyin in 2703673
- Changed badge address by @gouguoyin in 343a3c2
- 修改徽章地址 by @gouguoyin in 0a934f5
- Unified Unit test Format by @gouguoyin in 09b1657
- Bump codecov/codecov-action from 4 to 5 by @gouguoyin in cee97bf
- Support custom alphabet table by @gouguoyin in 3d21a8e
- Support custom alphabet table for base62 by @gouguoyin in e53528a
- Remove benchmark file by @gouguoyin in 77fb897
- Remove errors from errors.go to the current file by @gouguoyin in c286a54
- Remove Chinese annotations by @gouguoyin in c969116
- Change key type from
interface{}to[]byteby @gouguoyin in 1f43106 - Change privateKey and publicKey type from
interface{}to[]byteby @gouguoyin in d92e678 - Upgrade version by @gouguoyin in 7afcd5e
- github.com/golang-module/dongle -> github.com/dromara/dongle by @gouguoyin in 34d2c49
- Add
WithKeyandWithIVmethods by @gouguoyin in fdef30b - Remove github.com/golang-module/dongle by @gouguoyin in 42685d4
- Remove errors.go by @gouguoyin in f0b67fb
- Update content about
base62by @gouguoyin in 3623058 - Update content by @gouguoyin in 4a68d5f
- Upgrade version to
1.0.1by @gouguoyin in f81202d - Remove useless type conversions by @gouguoyin in 42d5ae3
v1.0.0 (2024-11-11)
🐛 修正
- AES/ECB/PKCS5 パディングによる panic を修正
📝 ドキュメント
- リポジトリとバッジURLを変更
What's Changed (5)
- Fixed: AES/ECB/PCKS5padding panic by xiaoyiyu in 5497c86
- Update content by @gouguoyin in f009269
- Upgrade version by @gouguoyin in 3293d42
- golang-module/dongle->dromara/dongle by @gouguoyin in de7c99b
- Changed badge url by @gouguoyin in 50691b6
より古いバージョンの更新ログについては、releases を参照してください