mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
PSP/Vita: Switch to using BearSSL for SSL support
This commit is contained in:
parent
2f2d6aadbb
commit
e555fdc21f
5 changed files with 89 additions and 25 deletions
4
Makefile
4
Makefile
|
@ -144,9 +144,9 @@ irix:
|
|||
# consoles builds require special handling, so are moved to
|
||||
# separate makefiles to avoid having one giant messy makefile
|
||||
psp:
|
||||
$(MAKE) -f src/Makefile_PSP PLAT=psp
|
||||
$(MAKE) -f misc/psp/Makefile PLAT=psp
|
||||
vita:
|
||||
$(MAKE) -f src/Makefile_vita PLAT=vita
|
||||
$(MAKE) -f misc/vita/Makefile PLAT=vita
|
||||
ps3:
|
||||
$(MAKE) -f src/Makefile_PS3 PLAT=ps3
|
||||
3ds:
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
TARGET = ClassiCube-psp
|
||||
SOURCES = $(wildcard src/*.c)
|
||||
OBJS = $(patsubst %.c, %.o, $(SOURCES))
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -g -O1 -fno-math-errno
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
LIBS = -lm -lpspgum -lpspgu -lpspge -lpspdisplay -lpspctrl
|
||||
|
||||
BUILD_PRX = 1
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = ClassiCube
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
TARGET = ClassiCube-psp
|
||||
SOURCES = $(wildcard src/*.c) $(wildcard third_party/bearssl/src/*.c)
|
||||
OBJS = $(patsubst %.c, %.o, $(SOURCES))
|
||||
|
||||
INCDIR = third_party/bearssl/inc
|
||||
CFLAGS = -g -O1 -fno-math-errno
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
LIBS = -lm -lpspgum -lpspgu -lpspge -lpspdisplay -lpspctrl
|
||||
|
||||
BUILD_PRX = 1
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = ClassiCube
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
49
misc/vita/Makefile
Normal file
49
misc/vita/Makefile
Normal file
|
@ -0,0 +1,49 @@
|
|||
PROJECT_TITLE := ClassiCube
|
||||
PROJECT_TITLEID := CUBE00200
|
||||
TARGET := ClassiCube-vita
|
||||
|
||||
BUILD_DIR := build-vita
|
||||
SOURCE_DIRS := src third_party/bearssl/src
|
||||
|
||||
CFLAGS += -Wl,-q -Ithird_party/bearssl/inc -O1
|
||||
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
|
||||
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
|
||||
|
||||
# Needed by psvDebugScreenPrintf
|
||||
LIBS += -lm -lSceDisplay_stub -lSceCtrl_stub -lSceTouch_stub -lSceGxm_stub
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
default: $(BUILD_DIR) $(TARGET).vpk
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
$(TARGET).vpk: eboot.bin param.sfo
|
||||
vita-pack-vpk -s param.sfo -b eboot.bin $(TARGET).vpk
|
||||
|
||||
eboot.bin: $(TARGET).velf
|
||||
vita-make-fself $(TARGET).velf eboot.bin
|
||||
|
||||
param.sfo:
|
||||
vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" "$(PROJECT_TITLE)" param.sfo
|
||||
|
||||
$(TARGET).velf: $(TARGET).elf
|
||||
arm-vita-eabi-strip -g $<
|
||||
vita-elf-create $< $@
|
||||
|
||||
$(TARGET).elf: $(OBJS)
|
||||
arm-vita-eabi-gcc $(CFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o : src/%.c
|
||||
arm-vita-eabi-gcc -c $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/%.o : third_party/bearssl/src/%.c
|
||||
arm-vita-eabi-gcc -c $(CFLAGS) -o $@ $<
|
||||
|
||||
# TODO: There's gotta be a better way of .o to .c than this
|
||||
|
||||
clean:
|
||||
rm $(TARGET).velf $(TARGET).elf $(TARGET).vpk param.sfo eboot.bin $(OBJS)
|
|
@ -266,6 +266,7 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_PSP
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_LOWMEM
|
||||
#undef CC_BUILD_FREETYPE
|
||||
#elif defined __3DS__
|
||||
|
@ -286,6 +287,7 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_PSVITA
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_LOWMEM
|
||||
#undef CC_BUILD_FREETYPE
|
||||
#elif defined _arch_dreamcast
|
||||
|
|
21
src/SSL.c
21
src/SSL.c
|
@ -418,10 +418,9 @@ cc_result SSL_Free(void* ctx_) {
|
|||
return 0;
|
||||
}
|
||||
#elif defined CC_BUILD_BEARSSL
|
||||
#include "bearssl.h"
|
||||
#define CERT_ATTRIBUTES
|
||||
#include "../misc/certs.h"
|
||||
#include "String.h"
|
||||
#include "bearssl.h"
|
||||
#include "../misc/certs.h"
|
||||
// https://github.com/unkaktus/bearssl/blob/master/samples/client_basic.c#L283
|
||||
#define SSL_ERROR_SHIFT 0xB5510000
|
||||
|
||||
|
@ -459,6 +458,20 @@ static void InjectEntropy(SSLContext* ctx) {
|
|||
|
||||
br_ssl_engine_inject_entropy(&ctx->sc.eng, buf, 32);
|
||||
}
|
||||
#elif defined CC_BUILD_PSP
|
||||
static void InjectEntropy(SSLContext* ctx) {
|
||||
char buf[32];
|
||||
// TODO: Is there an actual API to retrieve random data?
|
||||
|
||||
br_ssl_engine_inject_entropy(&ctx->sc.eng, buf, 32);
|
||||
}
|
||||
#elif defined CC_BUILD_VITA
|
||||
static void InjectEntropy(SSLContext* ctx) {
|
||||
char buf[32];
|
||||
// TODO: Is there an actual API to retrieve random data?
|
||||
|
||||
br_ssl_engine_inject_entropy(&ctx->sc.eng, buf, 32);
|
||||
}
|
||||
#else
|
||||
static void InjectEntropy(SSLContext* ctx) { }
|
||||
#endif
|
||||
|
@ -551,4 +564,4 @@ cc_result SSL_Write(void* ctx, const cc_uint8* data, cc_uint32 count, cc_uint32*
|
|||
}
|
||||
|
||||
cc_result SSL_Free(void* ctx) { return 0; }
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue