ponci_berlin/phpbaercode

v0.1.1 2021-05-21 16:37 UTC

README

这是一个根据 PoNCI-Berlin 规范生成的 BärCODE 的 PHP 库。

安装

通过 Composer

注意:此包尚未发布,因此必须手动安装。

$ composer require ponci_berlin/phpbaercode

使用方法

use ponci_berlin\phpbaercode\BaerCode;

$procedure = new Procedure(
    1,
    DateTime::createFromFormat(DateTimeInterface::RFC3339, "2021-05-01T08:00:00Z"),
);
$procedures = array($procedure);

$fist_name = "Max";
$last_name = "Mustermann";
$date_of_birth = DateTime::createFromFormat(DateTimeInterface::RFC3339, "1990-04-01T00:00:00Z");
$operator = "PoNC GmbH";
$kid = "<id_of_key_goes_here";

// $result is false for a negative test, and true for a positive vaccination.
$result = false

// privateKey is an instance of php3seclib\Crypt\EC\PrivateKey.
$baercode = new BaerCode(
    $first_name,
    $last_name,
    $date_of_birth,
    $procedures,
    $operator,
    $result,
    $kid,
    $privateKey,
    $aesKey
);

// Get the raw base64 BärCODE.
$baercode_b64 = $baercode->generate();

// Get the code encoded into a QR code. (This will return a binary string of the image)
$baercode_qr = $baercode->generate_qr();

测试

目前只有针对我们 Go 引用实现的集成测试,所以运行测试不会做很多事情。必须设置 SCRATCH_DIR 环境变量

$ SCRATCH_DIR=/tmp ./vendor/bin/phpunit

集成测试生成的文件将创建在 SCRATCH_DIR 中。

集成者的要求

对于需要接收 BärCODE 的人,集成者必须满足一系列要求,以确保不会有问题。

  • 每24小时提交一个新的密钥
  • 必须安全存储密钥
  • 提交的密钥必须存储七天,然后删除
  • 密钥轮换期间的错误被记录
  • 密钥轮换受到监控
  • BärCODE 对最终用户的展示包括“扫描此处”的文本(或当地语言的类似表述)以及到 https://scan.baercode.de 的链接
  • 集成者有独立的开发和生产环境

贡献

有关详细信息,请参阅 CONTRIBUTINGCODE_OF_CONDUCT

安全性

如果您发现任何与安全相关的问题,请通过电子邮件 daniel@ams-sec.org 联系,而不是使用问题跟踪器。