パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.6.2

webcrypto

Flutter用のクロスプラットフォームWeb暗号化APIの実装。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
5.2万
いいね数
84
Pub ポイント
140

パッケージをインストール

flutter pub add webcrypto

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

webcrypto パッケージは、Flutter向けのクロスプラットフォーム実装を提供し、Android、iOS、Web、macOS、Windows、Linuxでキーの生成、暗号化、復号化、デジタル署名などのセキュアな暗号操作を可能にします。ブラウザベースのWeb Cryptography APIと類似した一貫したインターフェースを提供しており、Flutterアプリケーションでの安全なデータ処理の実装を容易にします。プラットフォーム固有のコードなしに強力なセキュリティ機能が必要なアプリケーションにとって特に役立ちます。このパッケージはGoogleによってメンテナンスされており、GitHub上でオープンソースされています。

用途

  • セキュアなデータ暗号化
  • デジタル署名の検証
  • 鍵管理
  • クロスプラットフォーム暗号化
  • セキュアなトークン処理

主な機能

  • クロスプラットフォーム互換性
  • Web クリプト API の仕様に一致
  • 対称および非対称暗号化をサポートしています
  • オープンソースで Google がメンテナンスしています
  • ネイティブコードは不要です

適している対象

  • 安全なデータストレージを必要とするアプリ
  • 認証システム
  • セキュアな通信プロトコル
  • プライバシーに配慮したアプリケーション
  • Web Crypto APIに精通した開発者

注意事項

  • 暗号化の概念を理解する必要があります
  • ハイパフォーマンスな暗号処理が重いワークロードには適していません
  • Dartの非同期モデルに依存しています
  • 標準の Web クリプトアルゴリズムに限定
  • 本番環境での使用には追加の検証が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Cross-Platform Web Cryptography Implementation

This package provides a cross-platform implementation of the Web Cryptography API.

Disclaimer: This is not an officially supported Google product.

This packages provides an implementation of the Web Cryptography API across multiple platforms. Outside the browser, this package features a native implementation embedding BoringSSL using dart:ffi. When used inside a web browser this package wraps the window.crypto APIs and providing the same Dart API as the native implementation.

This way, package:webcrypto provides the same crypto API on Android, iOS, Web, Windows, Linux and Mac.

Example

import 'dart:convert' show base64, utf8;
import 'package:webcrypto/webcrypto.dart';

Future<void> main() async {
  final digest = await Hash.sha256.digestBytes(utf8.encode('Hello World'));
  print(base.encode(digest));
}

Coverage Status

Features:

  • Get random bytes
  • Digest (sha-1/sha-256/sha-384/sha-512)
  • HMAC (sign/verify)
  • RSASSA-PKCS1-v1_5 (sign/verify)
  • RSA-PSS (sign/verify)
  • ECDSA (sign/verify)
  • RSA-OAEP (encrypt/decrypt)
  • AES-CTR, AES-CBC, AES-GCM (encrypt/decrypt)
  • ECDH (deriveBits)
  • HKDF (deriveBits)
  • PBKDF2 (deriveBits)
  • BoringSSL, Chrome and Firefox implementations pass the same test cases.

Missing:

  • Exceptions and errors thrown for invalid input is not tested yet.
  • The native implementation executes on the main-thread, however, all expensive APIs are asynchronous, so they can be offloaded in the future.

For a discussion of the API design of this package, see doc/design-rationale-md.

System dependencies

When you have a dependency on package:webcrypto, it will use hooks to build BoringSSL. Thus, your system must have:

  • cmake, and,
  • a C compiler (like gcc or clang)

Limitations

This package has a few limitations compared to the Web Cryptography API. For a discussion of parity with Web Cryptography APIs see doc/webcrypto-parity.md.

  • deriveKey is not supported, however, keys can always be created from derivedBits which is supported.
  • wrapKey is not supported, however, keys can be exported and encrypted.
  • unwrapKey is not supported, however, keys can be decrypted and imported.
  • AES-KW is not supported because it does not support encrypt/decrypt.

Compatibility notes

This package has many tests cases to asses compatibility across the native implementation using BoringSSL and various browser implementations of the Web Cryptography APIs.

At the moment compatibility testing is limited to native implementation, Chrome, Firefox and Safari.

Known Issues:

  • Chrome and BoringSSL does not support valid ECDH spki-formatted keys exported by Firefox prior to version 72.
  • Firefox does not support PKCS8 import/export for ECDSA and ECDH keys.
  • Firefox does not handle counter wrap around for AES-CTR.
  • Safari does not support P-521 for ECDSA and ECDH.
  • The browser implementation of streaming methods for encryption, decryption, signing and verification buffers the entire input, because window.crypto does not expose a streaming API. However, the native implementation using BoringSSL does support streaming.
  • In browsers, operations backed by window.crypto.subtle require a secure context. When loaded from an insecure context, package:webcrypto throws UnsupportedError for those operations with guidance to use HTTPS or a trustworthy local origin such as localhost. fillRandomBytes() continues to work because it uses window.crypto.getRandomValues(), which browsers expose outside secure contexts.

References

カテゴリー

依存関係

依存関係一覧 5 件

  • code_assets^1.0.0
  • ffi^2.0.0
  • hooks^2.0.0
  • meta^1.3.0
  • native_toolchain_cmake^0.3.0

ソースリポジトリ

このパッケージを使用しているプロジェクト