Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to support stage2 compiler #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cert/asn1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub const Kind = union(enum) {
tag: Tag,
},
/// Allows the user how to decode the choice
choice: fn (decoder: *Decoder, id: u8) Decoder.Error!Value,
choice: *const fn (decoder: *Decoder, id: u8) Decoder.Error!Value,
/// When the element can be ignored
none,
};
Expand Down Expand Up @@ -455,7 +455,7 @@ test "Choice" {
.{
.with_schema = &.{
.{
.choice = callback,
.choice = &callback,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/handshake.zig
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ test "Client Hello" {
};
// zig fmt: on

var fb_reader = std.io.fixedBufferStream(&data).reader();
var fbs = std.io.fixedBufferStream(&data);
var fb_reader = fbs.reader();
var hasher = Sha256.init(.{});
var hs_reader = handshakeReader(fb_reader, &hasher);
const result = try hs_reader.decode();
Expand Down
8 changes: 4 additions & 4 deletions src/tls.zig
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pub fn bytesToTypedSlice(comptime T: type, bytes: anytype) []const T {
if (target_endianness == .Little) for (slice) |*element| {
element.* = @byteSwap(IntType, element.*);
};
return @bitCast([]const T, slice);
return @ptrCast([]const T, slice);
}

/// Keyshare represents the key exchange used to generate
Expand Down Expand Up @@ -477,7 +477,7 @@ pub const Extension = union(Tag) {

switch (@intToEnum(Extension.Tag, tag_byte)) {
.supported_versions => return Extension{ .supported_versions = bytesToTypedSlice(u16, extension_data[1..]) },
.psk_key_exchange_modes => return Extension{ .psk_key_exchange_modes = @bitCast(
.psk_key_exchange_modes => return Extension{ .psk_key_exchange_modes = @ptrCast(
[]const PskKeyExchangeMode,
extension_data[1..],
) },
Expand Down Expand Up @@ -609,7 +609,7 @@ pub const KeyExchange = struct {
pub const Curve = struct {
/// Error which can occur when generating the public key
pub const Error = crypto.errors.IdentityElementError;
genFn: fn (*Curve, [32]u8, *[32]u8) Error!void,
genFn: *const fn (*Curve, [32]u8, *[32]u8) Error!void,

/// Generates a new public key from a given private key.
/// Writes the output of the curve function to `public_key_out`.
Expand All @@ -622,7 +622,7 @@ pub const Curve = struct {
/// to generate keys.
pub const curves = struct {
const _x25519 = struct {
var state = Curve{ .genFn = gen };
var state = Curve{ .genFn = &gen };

fn gen(curve: *Curve, private_key: [32]u8, public_key_out: *[32]u8) !void {
_ = curve;
Expand Down