mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-08 14:56:12 -04:00
Start tidying up backend files a bit
This commit is contained in:
parent
08dabad8ca
commit
5fb24f6653
@ -11,7 +11,7 @@ include $(DEVKITPPC)/gamecube_rules
|
||||
# Directory where object files are placed
|
||||
BUILD_DIR := build/gc
|
||||
# List of directories containing source code
|
||||
SOURCE_DIRS := src third_party/bearssl/src
|
||||
SOURCE_DIRS := src src/gcwii third_party/bearssl/src
|
||||
# Name of the final output
|
||||
TARGET := ClassiCube-gc
|
||||
# Additional libraries to link against
|
||||
@ -62,6 +62,9 @@ $(TARGET).dol: $(TARGET).elf
|
||||
$(BUILD_DIR)/%.o: src/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: src/gcwii/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
|
@ -6,7 +6,7 @@ endif
|
||||
#---------------------------------------------------------------------------------
|
||||
# Configurable options
|
||||
#---------------------------------------------------------------------------------
|
||||
SOURCE_DIRS := src third_party/bearssl/src misc/ps2
|
||||
SOURCE_DIRS := src src/ps2 third_party/bearssl/src
|
||||
BUILD_DIR = build-ps2
|
||||
TARGET = ClassiCube-ps2
|
||||
|
||||
@ -100,10 +100,13 @@ $(TARGET)-min.elf : $(TARGET).elf
|
||||
$(BUILD_DIR)/%.o: src/%.c
|
||||
$(EE_CC) $(DEPFLAGS) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: src/ps2/%.c
|
||||
$(EE_CC) $(DEPFLAGS) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
|
||||
$(EE_CC) $(DEPFLAGS) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: misc/ps2/%.S
|
||||
$(BUILD_DIR)/%.o: src/ps2/%.S
|
||||
$(EE_CC) $(DEPFLAGS) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c # IOP modules
|
||||
|
@ -1,3 +1,12 @@
|
||||
ifeq ($(strip $(PSPSDK)),)
|
||||
$(warning "Please set PSPSDK variables in your environment. For example:")
|
||||
$(warning export PSPSDK=/usr/local/pspsk/psp/sdk)
|
||||
$(warning export PATH=/usr/local/pspsk/bin:$$PATH)
|
||||
$(warning Or)
|
||||
$(warning export PSPSDK=$$(shell psp-config --pspsdk-path))
|
||||
$(error Failed to find PSPSDK installation)
|
||||
endif
|
||||
|
||||
TARGET = ClassiCube-psp
|
||||
PSP_EBOOT_TITLE = ClassiCube
|
||||
PSP_EBOOT_ICON = misc/psp/ICON0.png
|
||||
@ -23,15 +32,6 @@ DEPFILES := $(OBJS:%.o=%.d)
|
||||
BUILD_PRX = 1
|
||||
EXTRA_TARGETS = $(BUILD_DIR) EBOOT.PBP
|
||||
|
||||
ifeq ($(strip $(PSPSDK)),)
|
||||
$(warning "Please set PSPSDK variables in your environment. For example:")
|
||||
$(warning export PSPSDK=/usr/local/pspsk/psp/sdk)
|
||||
$(warning export PATH=/usr/local/pspsk/bin:$$PATH)
|
||||
$(warning Or)
|
||||
$(warning export PSPSDK=$$(shell psp-config --pspsdk-path))
|
||||
$(error Failed to find PSPSDK installation)
|
||||
endif
|
||||
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ SOURCEPATH ../../src
|
||||
SOURCE Animations.c Audio.c Audio_Null.c AxisLinesRenderer.c Bitmap.c Block.c BlockPhysics.c Builder.c Camera.c Chat.c Commands.c Deflate.c Drawer.c Drawer2D.c Entity.c EntityComponents.c EntityRenderers.c EnvRenderer.c Event.c ExtMath.c FancyLighting.c Formats.c Game.c GameVersion.c Generator.c Graphics_GL1.c Graphics_SoftGPU.c Gui.c HeldBlockRenderer.c Http_Web.c Http_Worker.c Input.c InputHandler.c Inventory.c IsometricDrawer.c LBackend.c LScreens.c LWeb.c LWidgets.c Launcher.c Lighting.c Logger.c MapRenderer.c MenuOptions.c Menus.c Model.c Options.c PackedCol.c Particle.c Physics.c Picking.c Platform_Posix.c Protocol.c Queue.c Resources.c SSL.c Screens.c SelOutlineRenderer.c SelectionBox.c Server.c Stream.c String.c SystemFonts.c TexturePack.c TouchUI.c Utils.c Vectors.c Widgets.c World.c _autofit.c _cff.c _ftbase.c _ftbitmap.c _ftglyph.c _ftinit.c _ftsynth.c _psaux.c _pshinter.c _psmodule.c _sfnt.c _smooth.c _truetype.c _type1.c Vorbis.c Platform_Symbian.cpp Graphics_GL2.c Window_Symbian.cpp Audio_Symbian.cpp
|
||||
|
||||
SOURCEPATH ../../third_party/bearssl/src
|
||||
SOURCE aes_big_cbcdec.c aes_big_cbcenc.c aes_big_ctr.c aes_big_ctrcbc.c aes_big_dec.c aes_big_enc.c aes_common.c aes_ct64.c aes_ct64_cbcdec.c aes_ct64_cbcenc.c aes_ct64_ctr.c aes_ct64_ctrcbc.c aes_ct64_dec.c aes_ct64_enc.c aes_ct.c aes_ct_cbcdec.c aes_ct_cbcenc.c aes_ct_ctr.c aes_ct_ctrcbc.c aes_ct_dec.c aes_ct_enc.c aesctr_drbg.c aes_small_cbcdec.c aes_small_cbcenc.c aes_small_ctr.c aes_small_ctrcbc.c aes_small_dec.c aes_small_enc.c aes_x86ni.c aes_x86ni_cbcdec.c aes_x86ni_cbcenc.c aes_x86ni_ctr.c aes_x86ni_ctrcbc.c asn1enc.c a.txt ccm.c ccopy.c chacha20_ct.c chacha20_sse2.c config.h dec32be.c dec32le.c dec64be.c dec64le.c dig_oid.c dig_size.c ec_all_m31.c ec_c25519_i31.c ec_c25519_m31.c ec_c25519_m62.c ec_c25519_m64.c ec_curve25519.c ec_default.c ecdsa_atr.c ecdsa_default_vrfy_asn1.c ecdsa_default_vrfy_raw.c ecdsa_i31_bits.c ecdsa_i31_vrfy_asn1.c ecdsa_i31_vrfy_raw.c ec_p256_m31.c ec_p256_m62.c ec_p256_m64.c ec_prime_i31.c ec_secp256r1.c ec_secp384r1.c ec_secp521r1.c enc32be.c enc32le.c enc64be.c enc64le.c gcm.c ghash_ctmul64.c ghash_ctmul.c ghash_pclmul.c hmac.c hmac_ct.c hmac_drbg.c i31_add.c i31_bitlen.c i31_decmod.c i31_decode.c i31_decred.c i31_encode.c i31_fmont.c i31_iszero.c i31_moddiv.c i31_modpow2.c i31_modpow.c i31_montmul.c i31_mulacc.c i31_muladd.c i31_ninv31.c i31_reduce.c i31_rshift.c i31_sub.c i31_tmont.c i32_div32.c i62_modpow2.c inner.h md5.c md5sha1.c mgf1.c multihash.c poly1305_ctmul.c poly1305_ctmulq.c prf.c prf_md5sha1.c prf_sha256.c prf_sha384.c rsa_default_pkcs1_vrfy.c rsa_default_priv.c rsa_default_pub.c rsa_i31_pkcs1_vrfy.c rsa_i31_priv.c rsa_i31_pub.c rsa_i62_pkcs1_vrfy.c rsa_i62_priv.c rsa_i62_pub.c rsa_pkcs1_sig_pad.c rsa_pkcs1_sig_unpad.c sha1.c sha2big.c sha2small.c ssl_client.c ssl_client_default_rsapub.c ssl_client_full.c ssl_engine.c ssl_engine_default_aescbc.c ssl_engine_default_aesccm.c ssl_engine_default_aesgcm.c ssl_engine_default_chapol.c ssl_engine_default_ec.c ssl_engine_default_ecdsa.c ssl_engine_default_rsavrfy.c ssl_hashes.c ssl_hs_client.c ssl_io.c ssl_rec_cbc.c ssl_rec_ccm.c ssl_rec_chapol.c ssl_rec_gcm.c x509_minimal.c x509_minimal_full.c
|
||||
SOURCE aes_big_cbcdec.c aes_big_cbcenc.c aes_big_ctr.c aes_big_ctrcbc.c aes_big_dec.c aes_big_enc.c aes_common.c aes_ct64.c aes_ct64_cbcdec.c aes_ct64_cbcenc.c aes_ct64_ctr.c aes_ct64_ctrcbc.c aes_ct64_dec.c aes_ct64_enc.c aes_ct.c aes_ct_cbcdec.c aes_ct_cbcenc.c aes_ct_ctr.c aes_ct_ctrcbc.c aes_ct_dec.c aes_ct_enc.c aesctr_drbg.c aes_small_cbcdec.c aes_small_cbcenc.c aes_small_ctr.c aes_small_ctrcbc.c aes_small_dec.c aes_small_enc.c aes_x86ni.c aes_x86ni_cbcdec.c aes_x86ni_cbcenc.c aes_x86ni_ctr.c aes_x86ni_ctrcbc.c asn1enc.c ccm.c ccopy.c chacha20_ct.c chacha20_sse2.c dec32be.c dec32le.c dec64be.c dec64le.c dig_oid.c dig_size.c ec_all_m31.c ec_c25519_i31.c ec_c25519_m31.c ec_c25519_m62.c ec_c25519_m64.c ec_curve25519.c ec_default.c ecdsa_atr.c ecdsa_default_vrfy_asn1.c ecdsa_default_vrfy_raw.c ecdsa_i31_bits.c ecdsa_i31_vrfy_asn1.c ecdsa_i31_vrfy_raw.c ec_p256_m31.c ec_p256_m62.c ec_p256_m64.c ec_prime_i31.c ec_secp256r1.c ec_secp384r1.c ec_secp521r1.c enc32be.c enc32le.c enc64be.c enc64le.c gcm.c ghash_ctmul64.c ghash_ctmul.c ghash_pclmul.c hmac.c hmac_ct.c hmac_drbg.c i31_add.c i31_bitlen.c i31_decmod.c i31_decode.c i31_decred.c i31_encode.c i31_fmont.c i31_iszero.c i31_moddiv.c i31_modpow2.c i31_modpow.c i31_montmul.c i31_mulacc.c i31_muladd.c i31_ninv31.c i31_reduce.c i31_rshift.c i31_sub.c i31_tmont.c i32_div32.c i62_modpow2.c md5.c md5sha1.c multihash.c poly1305_ctmul.c poly1305_ctmulq.c prf.c prf_md5sha1.c prf_sha256.c prf_sha384.c rsa_default_pkcs1_vrfy.c rsa_default_priv.c rsa_default_pub.c rsa_i31_pkcs1_vrfy.c rsa_i31_priv.c rsa_i31_pub.c rsa_i62_pkcs1_vrfy.c rsa_i62_priv.c rsa_i62_pub.c rsa_pkcs1_sig_unpad.c sha1.c sha2big.c sha2small.c ssl_client.c ssl_client_default_rsapub.c ssl_client_full.c ssl_engine.c ssl_engine_default_aescbc.c ssl_engine_default_aesccm.c ssl_engine_default_aesgcm.c ssl_engine_default_chapol.c ssl_engine_default_ec.c ssl_engine_default_ecdsa.c ssl_engine_default_rsavrfy.c ssl_hashes.c ssl_hs_client.c ssl_io.c ssl_rec_cbc.c ssl_rec_ccm.c ssl_rec_chapol.c ssl_rec_gcm.c x509_minimal.c x509_minimal_full.c
|
||||
|
||||
CAPABILITY NetworkServices ReadUserData UserEnvironment WriteUserData
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
ifeq ($(strip $(VITASDK)),)
|
||||
$(warning "Please set VITASDK variables in your environment. For example:")
|
||||
$(warning export VITASDK=/usr/local/vitasdk)
|
||||
$(warning export PATH=$$VITASDK/bin:$$PATH)
|
||||
$(error Failed to find VitaSDK installation)
|
||||
endif
|
||||
|
||||
PROJECT_TITLE := ClassiCube
|
||||
PROJECT_TITLEID := CUBE00200
|
||||
TARGET := ClassiCube-vita
|
||||
@ -15,13 +22,6 @@ LIBS += -lm -lSceDisplay_stub -lSceCtrl_stub -lSceTouch_stub -lSceGxm_stub -lSce
|
||||
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
|
||||
DEPFILES := $(OBJS:%.o=%.d)
|
||||
|
||||
ifeq ($(strip $(VITASDK)),)
|
||||
$(warning "Please set VITASDK variables in your environment. For example:")
|
||||
$(warning export VITASDK=/usr/local/vitasdk)
|
||||
$(warning export PATH=$$VITASDK/bin:$$PATH)
|
||||
$(error Failed to find VitaSDK installation)
|
||||
endif
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
|
@ -11,7 +11,7 @@ include $(DEVKITPPC)/wii_rules
|
||||
# Directory where object files are placed
|
||||
BUILD_DIR := build/wii
|
||||
# List of directories containing source code
|
||||
SOURCE_DIRS := src third_party/bearssl/src
|
||||
SOURCE_DIRS := src src/gcwii third_party/bearssl/src
|
||||
# Name of the final output
|
||||
TARGET := ClassiCube-wii
|
||||
# Additional libraries to link against
|
||||
@ -62,6 +62,9 @@ $(TARGET).dol: $(TARGET).elf
|
||||
$(BUILD_DIR)/%.o: src/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: src/gcwii/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
|
@ -7,7 +7,7 @@ endif
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET = ClassiCube-xbox
|
||||
XBE_TITLE = ClassiCube
|
||||
SOURCE_DIRS = src third_party/bearssl/src
|
||||
SOURCE_DIRS = src src/xbox third_party/bearssl/src
|
||||
SHADER_OBJS = misc/xbox/vs_coloured.inl misc/xbox/vs_textured.inl misc/xbox/ps_coloured.inl misc/xbox/ps_textured.inl
|
||||
BUILD_DIR = build/xbox
|
||||
|
||||
@ -90,7 +90,10 @@ $(TARGET).exe : $(OBJS)
|
||||
$(BUILD_DIR)/%.o: src/%.c
|
||||
nxdk-cc $(NXDK_CFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: src/%.S
|
||||
$(BUILD_DIR)/%.o: src/xbox/%.c
|
||||
nxdk-cc $(NXDK_CFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: src/xbox/%.S
|
||||
nxdk-as $(NXDK_ASFLAGS) $(ASFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
|
||||
|
15
third_party/bearssl/src/inner.h
vendored
15
third_party/bearssl/src/inner.h
vendored
@ -1908,14 +1908,6 @@ unsigned br_aes_x86ni_keysched_dec(unsigned char *skni,
|
||||
* RSA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Apply proper PKCS#1 v1.5 padding (for signatures). 'hash_oid' is
|
||||
* the encoded hash function OID, or NULL.
|
||||
*/
|
||||
uint32_t br_rsa_pkcs1_sig_pad(const unsigned char *hash_oid,
|
||||
const unsigned char *hash, size_t hash_len,
|
||||
uint32_t n_bitlen, unsigned char *x);
|
||||
|
||||
/*
|
||||
* Check PKCS#1 v1.5 padding (for signatures). 'hash_oid' is the encoded
|
||||
* hash function OID, or NULL. The provided 'sig' value is _after_ the
|
||||
@ -1926,13 +1918,6 @@ uint32_t br_rsa_pkcs1_sig_unpad(const unsigned char *sig, size_t sig_len,
|
||||
const unsigned char *hash_oid, size_t hash_len,
|
||||
unsigned char *hash_out);
|
||||
|
||||
/*
|
||||
* Compute MGF1 for a given seed, and XOR the output into the provided
|
||||
* buffer.
|
||||
*/
|
||||
void br_mgf1_xor(void *data, size_t len,
|
||||
const br_hash_class *dig, const void *seed, size_t seed_len);
|
||||
|
||||
/*
|
||||
* Inner function for RSA key generation; used by the "i31" and "i62"
|
||||
* implementations.
|
||||
|
56
third_party/bearssl/src/mgf1.c
vendored
56
third_party/bearssl/src/mgf1.c
vendored
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see inner.h */
|
||||
void
|
||||
br_mgf1_xor(void *data, size_t len,
|
||||
const br_hash_class *dig, const void *seed, size_t seed_len)
|
||||
{
|
||||
unsigned char *buf;
|
||||
size_t u, hlen;
|
||||
uint32_t c;
|
||||
|
||||
buf = data;
|
||||
hlen = br_digest_size(dig);
|
||||
for (u = 0, c = 0; u < len; u += hlen, c ++) {
|
||||
br_hash_compat_context hc;
|
||||
unsigned char tmp[64];
|
||||
size_t v;
|
||||
|
||||
hc.vtable = dig;
|
||||
dig->init(&hc.vtable);
|
||||
dig->update(&hc.vtable, seed, seed_len);
|
||||
br_enc32be(tmp, c);
|
||||
dig->update(&hc.vtable, tmp, 4);
|
||||
dig->out(&hc.vtable, tmp);
|
||||
for (v = 0; v < hlen; v ++) {
|
||||
if ((u + v) >= len) {
|
||||
break;
|
||||
}
|
||||
buf[u + v] ^= tmp[v];
|
||||
}
|
||||
}
|
||||
}
|
100
third_party/bearssl/src/rsa_pkcs1_sig_pad.c
vendored
100
third_party/bearssl/src/rsa_pkcs1_sig_pad.c
vendored
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see inner.h */
|
||||
uint32_t
|
||||
br_rsa_pkcs1_sig_pad(const unsigned char *hash_oid,
|
||||
const unsigned char *hash, size_t hash_len,
|
||||
uint32_t n_bitlen, unsigned char *x)
|
||||
{
|
||||
size_t u, x3, xlen;
|
||||
|
||||
/*
|
||||
* Padded hash value has format:
|
||||
* 00 01 FF .. FF 00 30 x1 30 x2 06 x3 OID 05 00 04 x4 HASH
|
||||
*
|
||||
* with the following rules:
|
||||
*
|
||||
* -- Total length is equal to the modulus length (unsigned
|
||||
* encoding).
|
||||
*
|
||||
* -- There must be at least eight bytes of value 0xFF.
|
||||
*
|
||||
* -- x4 is equal to the hash length (hash_len).
|
||||
*
|
||||
* -- x3 is equal to the encoded OID value length (hash_oid[0]).
|
||||
*
|
||||
* -- x2 = x3 + 4.
|
||||
*
|
||||
* -- x1 = x2 + x4 + 4 = x3 + x4 + 8.
|
||||
*
|
||||
* Note: the "05 00" is optional (signatures with and without
|
||||
* that sequence exist in practice), but notes in PKCS#1 seem to
|
||||
* indicate that the presence of that sequence (specifically,
|
||||
* an ASN.1 NULL value for the hash parameters) may be slightly
|
||||
* more "standard" than the opposite.
|
||||
*/
|
||||
xlen = (n_bitlen + 7) >> 3;
|
||||
|
||||
if (hash_oid == NULL) {
|
||||
if (xlen < hash_len + 11) {
|
||||
return 0;
|
||||
}
|
||||
x[0] = 0x00;
|
||||
x[1] = 0x01;
|
||||
u = xlen - hash_len;
|
||||
memset(x + 2, 0xFF, u - 3);
|
||||
x[u - 1] = 0x00;
|
||||
} else {
|
||||
x3 = hash_oid[0];
|
||||
|
||||
/*
|
||||
* Check that there is enough room for all the elements,
|
||||
* including at least eight bytes of value 0xFF.
|
||||
*/
|
||||
if (xlen < (x3 + hash_len + 21)) {
|
||||
return 0;
|
||||
}
|
||||
x[0] = 0x00;
|
||||
x[1] = 0x01;
|
||||
u = xlen - x3 - hash_len - 11;
|
||||
memset(x + 2, 0xFF, u - 2);
|
||||
x[u] = 0x00;
|
||||
x[u + 1] = 0x30;
|
||||
x[u + 2] = x3 + hash_len + 8;
|
||||
x[u + 3] = 0x30;
|
||||
x[u + 4] = x3 + 4;
|
||||
x[u + 5] = 0x06;
|
||||
memcpy(x + u + 6, hash_oid, x3 + 1);
|
||||
u += x3 + 7;
|
||||
x[u ++] = 0x05;
|
||||
x[u ++] = 0x00;
|
||||
x[u ++] = 0x04;
|
||||
x[u ++] = hash_len;
|
||||
}
|
||||
memcpy(x + u, hash, hash_len);
|
||||
return 1;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user