Files
pico-hsm/src/hsm/cmd_mse.c
Pol Henarejos dba614ed36 Relicense project under the GNU Affero General Public License v3 (AGPLv3)
and add the Enterprise / Commercial licensing option.

Main changes:
- Replace GPLv3 headers with AGPLv3 headers in source files.
- Update LICENSE file to the full AGPLv3 text.
- Add ENTERPRISE.md describing the dual-licensing model:
  * Community Edition: AGPLv3 (strong copyleft, including network use).
  * Enterprise / Commercial Edition: proprietary license for production /
    multi-user / OEM use without the obligation to disclose derivative code.
- Update README with a new "License and Commercial Use" section pointing to
  ENTERPRISE.md and clarifying how companies can obtain a commercial license.

Why this change:
- AGPLv3 ensures that modified versions offered as a service or deployed
  in production environments must provide corresponding source code.
- The Enterprise / Commercial edition provides organizations with an
  alternative proprietary license that allows internal, large-scale, or OEM
  use (bulk provisioning, policy enforcement, inventory / revocation,
  custom attestation, signed builds) without AGPL disclosure obligations.

This commit formally marks the first release that is dual-licensed:
AGPLv3 for the Community Edition and a proprietary commercial license
for Enterprise customers.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2025-10-26 20:18:45 +01:00

90 lines
3.2 KiB
C

/*
* This file is part of the Pico HSM distribution (https://github.com/polhenarejos/pico-hsm).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "sc_hsm.h"
#include "asn1.h"
#include "oid.h"
#include "eac.h"
#include "files.h"
#include "cvc.h"
file_t *ef_puk_aut = NULL;
int cmd_mse() {
int p1 = P1(apdu);
int p2 = P2(apdu);
if (p2 != 0xA4 && p2 != 0xA6 && p2 != 0xAA && p2 != 0xB4 && p2 != 0xB6 && p2 != 0xB8) {
return SW_INCORRECT_P1P2();
}
if (p1 & 0x1) { //SET
uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL;
uint16_t tag_len = 0;
asn1_ctx_t ctxi;
asn1_ctx_init(apdu.data, (uint16_t)apdu.nc, &ctxi);
while (walk_tlv(&ctxi, &p, &tag, &tag_len, &tag_data)) {
if (tag == 0x80) {
if (p2 == 0xA4) {
if (tag_len == 10 &&
memcmp(tag_data, OID_ID_CA_ECDH_AES_CBC_CMAC_128, tag_len) == 0) {
sm_set_protocol(MSE_AES);
}
}
}
else if (tag == 0x83) {
if (tag_len == 1) {
}
else {
if (p2 == 0xB6) {
if (puk_store_select_chr(tag_data) == PICOKEY_OK) {
return SW_OK();
}
}
else if (p2 == 0xA4) { /* Aut */
for (uint8_t i = 0; i < MAX_PUK; i++) {
file_t *ef = search_file(EF_PUK + i);
if (!ef) {
break;
}
if (!file_has_data(ef)) {
break;
}
uint16_t chr_len = 0;
const uint8_t *chr = cvc_get_chr(file_get_data(ef),
file_get_size(ef),
&chr_len);
if (memcmp(chr, tag_data, chr_len) == 0) {
ef_puk_aut = ef;
if (puk_status[i] == 1) {
return SW_CONDITIONS_NOT_SATISFIED(); // It is correct
}
return SW_OK();
}
}
}
return SW_REFERENCE_NOT_FOUND();
}
}
}
}
else {
return SW_INCORRECT_P1P2();
}
return SW_OK();
}