iPXE
rsa_sha256.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00025 
00026 #include <ipxe/rsa.h>
00027 #include <ipxe/sha256.h>
00028 #include <ipxe/asn1.h>
00029 #include <ipxe/tls.h>
00030 
00031 /** "sha256WithRSAEncryption" object identifier */
00032 static uint8_t oid_sha256_with_rsa_encryption[] =
00033         { ASN1_OID_SHA256WITHRSAENCRYPTION };
00034 
00035 /** "sha256WithRSAEncryption" OID-identified algorithm */
00036 struct asn1_algorithm sha256_with_rsa_encryption_algorithm __asn1_algorithm = {
00037         .name = "sha256WithRSAEncryption",
00038         .pubkey = &rsa_algorithm,
00039         .digest = &sha256_algorithm,
00040         .oid = ASN1_OID_CURSOR ( oid_sha256_with_rsa_encryption ),
00041 };
00042 
00043 /** SHA-256 digestInfo prefix */
00044 static const uint8_t rsa_sha256_prefix_data[] =
00045         { RSA_DIGESTINFO_PREFIX ( SHA256_DIGEST_SIZE, ASN1_OID_SHA256 ) };
00046 
00047 /** SHA-256 digestInfo prefix */
00048 struct rsa_digestinfo_prefix rsa_sha256_prefix __rsa_digestinfo_prefix = {
00049         .digest = &sha256_algorithm,
00050         .data = rsa_sha256_prefix_data,
00051         .len = sizeof ( rsa_sha256_prefix_data ),
00052 };
00053 
00054 /** RSA with SHA-256 signature hash algorithm */
00055 struct tls_signature_hash_algorithm tls_rsa_sha256 __tls_sig_hash_algorithm = {
00056         .code = {
00057                 .signature = TLS_RSA_ALGORITHM,
00058                 .hash = TLS_SHA256_ALGORITHM,
00059         },
00060         .pubkey = &rsa_algorithm,
00061         .digest = &sha256_algorithm,
00062 };