Skip to content

更新ログ ​

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 KEY PEM ブロックに 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 SetMode method to replace the existing SetOrder method 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)

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 WriteAfterN struct, 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 src to []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)

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)

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 util package to utils by @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.go to doc.go by @gouguoyin in 0a86b4a
  • refactor(utils): Add package comment in doc.go by @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.6 by @gouguoyin in 4a16814
  • refactor(hash): Use io.CopyBuffer to replace manual reading of the buffer, simplifying the implementation of stream and hmac methods 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.CopyBuffer to 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.CopyBuffer by @gouguoyin in bc1c6ab
  • refactor(encoder):Simplify streaming process with io.CopyBuffer by @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 xtea algorithm 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)

v1.1.4 (2025-09-23) ​

✨ 新機能 ​

  • twofish 暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含む)

🔧 リファクタリング ​

  • グローバルデフォルトインスタンス使用時のプロパティ汚染を防ぐため、メソッドレシーバーをポインタから値に変更、呼び出し側 API への影響はなし
What's Changed (5)

v1.1.3 (2025-09-15) ​

✨ 新機能 ​

  • testify 依存関係を v1.11.1 に更新

🐛 修正 ​

  • 3DES 対称暗号化アルゴリズムの 16 バイトキー互換性を最適化
  • DES 対称暗号化アルゴリズムのサポートされていない GCM モード検証を最適化
  • 3DES 対称暗号化アルゴリズムのサポートされていない GCM モード検証を最適化
  • Blowfish 対称暗号化アルゴリズムのサポートされていない GCM モード検証を最適化

🔧 リファクタリング ​

  • Salsa20 暗号化アルゴリズムサポートを追加(標準処理とストリーム処理を含む)
What's Changed (21)

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)

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 SM3 hash 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.Rc4Cipher to *cipher.Rc4Cipher by @gouguoyin in 4bcba4e
  • refactor(tea): cipher.TeaCipher -> *cipher.TeaCipher by @gouguoyin in f90f82c
  • refactor(tea): cipher.BlowfishCipher -> *cipher.BlowfishCipher by @gouguoyin in af4db9d
  • refactor(crypto/cipher):Rename the padding function and remove the internal dispatcher by @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.NewFile instead of strings.NewReader and bytes.NewReader by @gouguoyin in b77f6c3
  • refactor: Use the errors.As function instead of type assertion by @gouguoyin in c4ddfd0
  • feat: Add FromFile method 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.Write by @gouguoyin in 966bdd5
  • refactor(mock): Added mock/hash.go to simulate error conditions of the hash.Hash interface 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.NewFile instead of strings.NewReader and bytes.NewReader by @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)

v1.0.1 (2024-11-22) ​

✨ 新機能 ​

  • base62 カスタムエンコードテーブルをサポート

🐛 修正 ​

  • AES-CBC-PKCS5 暗号化復号化エラーのBugを修正

🔧 リファクタリング ​

  • コード品質と組織構造を最適化
  • errors.go ファイルを削除、エラー情報を各ファイルに移行
  • 単体テストフォーマットを統一
  • 中文コメントを削除
What's Changed (22)

v1.0.0 (2024-11-11) ​

🐛 修正 ​

  • AES/ECB/PKCS5 パディングによる panic を修正

📝 ドキュメント ​

  • リポジトリとバッジURLを変更
What's Changed (5)

より古いバージョンの更新ログについては、releases を参照してください

MITライセンスに基づいて公開されており、許可なく複製することは禁止されています