17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5dae6ba85Sbubbva * Common Development and Distribution License (the "License"). 6dae6ba85Sbubbva * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 229b009fc1SValerie Bubb Fenwick * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 24*6ea3c060SGarrett D'Amore /* 25*6ea3c060SGarrett D'Amore * Copyright 2010 Nexenta Systems, Inc. All rights reserved. 26*6ea3c060SGarrett D'Amore */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #ifndef _SYS_CRYPTO_ELFSIGN_H 297c478bd9Sstevel@tonic-gate #define _SYS_CRYPTO_ELFSIGN_H 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * Consolidation Private Interface for elfsign/libpkcs11/kcfd 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <sys/types.h> 407c478bd9Sstevel@tonic-gate #include <sys/param.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Project Private structures and types used for communication between kcfd 447c478bd9Sstevel@tonic-gate * and KCF over the door. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate typedef enum ELFsign_status_e { 487c478bd9Sstevel@tonic-gate ELFSIGN_UNKNOWN, 497c478bd9Sstevel@tonic-gate ELFSIGN_SUCCESS, 507c478bd9Sstevel@tonic-gate ELFSIGN_FAILED, 517c478bd9Sstevel@tonic-gate ELFSIGN_NOTSIGNED, 527c478bd9Sstevel@tonic-gate ELFSIGN_INVALID_CERTPATH, 537c478bd9Sstevel@tonic-gate ELFSIGN_INVALID_ELFOBJ, 544ff712c4SValerie Bubb Fenwick ELFSIGN_UNAVAILABLE 557c478bd9Sstevel@tonic-gate } ELFsign_status_t; 567c478bd9Sstevel@tonic-gate 574ff712c4SValerie Bubb Fenwick 587c478bd9Sstevel@tonic-gate #define SIG_MAX_LENGTH 1024 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #define ELF_SIGNATURE_SECTION ".SUNW_signature" 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate typedef uint32_t filesig_vers_t; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * File Signature Structure 667c478bd9Sstevel@tonic-gate * Applicable to ELF and other file formats 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate struct filesignatures { 697c478bd9Sstevel@tonic-gate uint32_t filesig_cnt; /* count of signatures */ 707c478bd9Sstevel@tonic-gate uint32_t filesig_pad; /* unused */ 717c478bd9Sstevel@tonic-gate union { 727c478bd9Sstevel@tonic-gate char filesig_data[1]; 737c478bd9Sstevel@tonic-gate struct filesig { /* one of these for each signature */ 747c478bd9Sstevel@tonic-gate uint32_t filesig_size; 757c478bd9Sstevel@tonic-gate filesig_vers_t filesig_version; 767c478bd9Sstevel@tonic-gate union { 777c478bd9Sstevel@tonic-gate struct filesig_version1 { 787c478bd9Sstevel@tonic-gate uint32_t filesig_v1_dnsize; 797c478bd9Sstevel@tonic-gate uint32_t filesig_v1_sigsize; 807c478bd9Sstevel@tonic-gate uint32_t filesig_v1_oidsize; 817c478bd9Sstevel@tonic-gate char filesig_v1_data[1]; 827c478bd9Sstevel@tonic-gate } filesig_v1; 837c478bd9Sstevel@tonic-gate struct filesig_version3 { 847c478bd9Sstevel@tonic-gate uint64_t filesig_v3_time; 857c478bd9Sstevel@tonic-gate uint32_t filesig_v3_dnsize; 867c478bd9Sstevel@tonic-gate uint32_t filesig_v3_sigsize; 877c478bd9Sstevel@tonic-gate uint32_t filesig_v3_oidsize; 887c478bd9Sstevel@tonic-gate char filesig_v3_data[1]; 897c478bd9Sstevel@tonic-gate } filesig_v3; 907c478bd9Sstevel@tonic-gate } _u2; 917c478bd9Sstevel@tonic-gate } filesig_sig; 927c478bd9Sstevel@tonic-gate uint64_t filesig_align; 937c478bd9Sstevel@tonic-gate } _u1; 947c478bd9Sstevel@tonic-gate }; 957c478bd9Sstevel@tonic-gate #define filesig_sig _u1.filesig_sig 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate #define filesig_v1_dnsize _u2.filesig_v1.filesig_v1_dnsize 987c478bd9Sstevel@tonic-gate #define filesig_v1_sigsize _u2.filesig_v1.filesig_v1_sigsize 997c478bd9Sstevel@tonic-gate #define filesig_v1_oidsize _u2.filesig_v1.filesig_v1_oidsize 1007c478bd9Sstevel@tonic-gate #define filesig_v1_data _u2.filesig_v1.filesig_v1_data 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #define filesig_v3_time _u2.filesig_v3.filesig_v3_time 1037c478bd9Sstevel@tonic-gate #define filesig_v3_dnsize _u2.filesig_v3.filesig_v3_dnsize 1047c478bd9Sstevel@tonic-gate #define filesig_v3_sigsize _u2.filesig_v3.filesig_v3_sigsize 1057c478bd9Sstevel@tonic-gate #define filesig_v3_oidsize _u2.filesig_v3.filesig_v3_oidsize 1067c478bd9Sstevel@tonic-gate #define filesig_v3_data _u2.filesig_v3.filesig_v3_data 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define filesig_ALIGN(s) (((s) + sizeof (uint64_t) - 1) & \ 1094ba03c27Sjohnz (-sizeof (uint64_t))) 1107c478bd9Sstevel@tonic-gate #define filesig_next(ptr) (struct filesig *)((void *)((char *)(ptr) + \ 1117c478bd9Sstevel@tonic-gate filesig_ALIGN((ptr)->filesig_size))) 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define FILESIG_UNKNOWN 0 /* unrecognized version */ 1147c478bd9Sstevel@tonic-gate #define FILESIG_VERSION1 1 /* version1, all but sig section */ 1157c478bd9Sstevel@tonic-gate #define FILESIG_VERSION2 2 /* version1 format, SHF_ALLOC only */ 1167c478bd9Sstevel@tonic-gate #define FILESIG_VERSION3 3 /* version3, all but sig section */ 1177c478bd9Sstevel@tonic-gate #define FILESIG_VERSION4 4 /* version3 format, SHF_ALLOC only */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate #endif 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate #endif /* _SYS_CRYPTO_ELFSIGN_H */ 128