kms 0.2.0 copy "kms: ^0.2.0" to clipboard
kms: ^0.2.0 copied to clipboard

unlistedoutdated

Key Management Service (KMS) API for managing cryptographic keys securely.

Pub Package Github Actions CI

Overview #

This package gives you a vendor-agnostic API for accessing Key Management Service (KMS) products. Many operating systems and major cloud platforms (AWS, Azure, Google) offer such APIs. KMS adapters are subclasses of Kms.

You may want to start with MemoryKms, which works in all platforms. It uses cryptographic implementations in our sibling project, package:cryptography.

Getting started #

1.Add dependency #

In pubspec.yaml:

dependencies:
  kms: ^0.2.0

2.Use #

For key exchange #

import 'package:kms/kms.dart';

Future<void> main() async {
  final kms = MemoryKms();

  // Create our key pairs
  final kmsKey = await kms.createKeyPair(
    keyRingId: 'example',
    keyExchangeType: KeyExchangeType.ecdhCurve25519, // Enable ECDH-Curve25519
    signatureType: null, // Disable digital signature
  );

  // Generate a Curve25519 public key for the peer.
  // In real life, you receive the public key from some source.
  final peerKmsKey = await kms.createKeyPair(
    keyRingId: 'example',
    keyExchangeType: KeyExchangeType.ecdhCurve25519,
    signatureType: null,
  );
  final peerPublicKey = await kms.getPublicKey(kmsKey1);

  // Generate a shared secret key
  final secretKey = await kms.sharedSecret(kmsKey, peerPublicKey);
  print('Secret key: ${secretKey.bytes}');

  // Delete the key pair
  await kms.delete(kmsKey);
}

For digital signature #

import 'package:kms/kms.dart';

Future<void> main() async {
  final kms = MemoryKms();

  // Create the key pair
  final kmsKey = await kms.createKeyPair(
    keyRingId: 'example',
    keyExchangeType: null, // Disable key exchange
    signatureType: SignatureType.ecdsaP256Sha256, // Enable ECDSA-P256-SHA256
  );

  // Generate a signature
  final data = <int>[1,2,3];
  final signature = await kms.sign(data, kmsKey);
  print('Signature: ${signature.bytes}');
  print('Public key: ${signature.publicKey}');

  // Delete the key pair
  await kms.delete(kmsKey);
}
10
likes
0
pub points
0%
popularity

Publisher

verified publisherdint.dev

Key Management Service (KMS) API for managing cryptographic keys securely.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cryptography, meta

More

Packages that depend on kms