Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
rtas
Commits
f46b0a39
Commit
f46b0a39
authored
Oct 5, 2017
by
pln
Browse files
Options
Downloads
Patches
Plain Diff
different delegations
parent
02dac31c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+14
-5
14 additions, 5 deletions
src/main.rs
with
14 additions
and
5 deletions
src/main.rs
+
14
−
5
View file @
f46b0a39
...
@@ -31,12 +31,12 @@ mod trusted {
...
@@ -31,12 +31,12 @@ mod trusted {
}
}
}
}
// opaque representation of secure data
#[derive(Debug)]
#[derive(Debug)]
pub
struct
Sec
<
T
>
{
pub
struct
Sec
<
T
>
{
data
:
T
,
data
:
T
,
}
}
// opaque representation of secure data
impl
<
T
>
Sec
<
T
>
{
impl
<
T
>
Sec
<
T
>
{
pub
unsafe
fn
new
(
d
:
T
)
->
Self
{
pub
unsafe
fn
new
(
d
:
T
)
->
Self
{
Sec
{
data
:
d
}
Sec
{
data
:
d
}
...
@@ -51,7 +51,7 @@ mod trusted {
...
@@ -51,7 +51,7 @@ mod trusted {
unsafe
{
Sec
::
new
(
s1
.get
()
+
s2
.get
())
}
unsafe
{
Sec
::
new
(
s1
.get
()
+
s2
.get
())
}
}
}
// cipher
by a
closure
//
in place transformation by a
cipher closure
f
fn
cipher
<
T
,
F
>
(
s
:
&
mut
T
,
mut
f
:
F
)
fn
cipher
<
T
,
F
>
(
s
:
&
mut
T
,
mut
f
:
F
)
where
where
T
:
Sized
,
T
:
Sized
,
...
@@ -64,6 +64,7 @@ mod trusted {
...
@@ -64,6 +64,7 @@ mod trusted {
}
}
}
}
// opaque representation of encrypted data
#[derive(Debug)]
#[derive(Debug)]
pub
struct
Enc
<
T
>
{
pub
struct
Enc
<
T
>
{
data
:
T
,
data
:
T
,
...
@@ -89,8 +90,6 @@ mod trusted {
...
@@ -89,8 +90,6 @@ mod trusted {
unsafe
{
self
.get_unsafe
()
}
unsafe
{
self
.get_unsafe
()
}
}
}
}
}
}
}
use
trusted
::
*
;
use
trusted
::
*
;
...
@@ -106,13 +105,23 @@ fn main() {
...
@@ -106,13 +105,23 @@ fn main() {
// user code in `safe` Rust
// user code in `safe` Rust
fn
user1
(
d
:
&
Sec
<
u32
>
,
e
:
&
Enc
<
u32
>
)
{
fn
user1
(
d
:
&
Sec
<
u32
>
,
e
:
&
Enc
<
u32
>
)
{
println!
(
"user1 {:?}, {:?}"
,
d
,
e
);
println!
(
"user1 {:?}, {:?}"
,
d
,
e
);
user2
(
&
sec_add_u32
(
d
,
&
e
.get
(
auth
(
"abc"
)
.unwrap
())));
let
a
=
auth
(
"abc"
)
.unwrap
();
user2
(
&
sec_add_u32
(
d
,
&
e
.get
(
a
)));
user3
(
d
,
&
e
.get
(
a
));
user4
(
d
,
e
,
a
);
}
}
fn
user2
(
d
:
&
Sec
<
u32
>
)
{
fn
user2
(
d
:
&
Sec
<
u32
>
)
{
println!
(
"user2 {:?}"
,
d
);
println!
(
"user2 {:?}"
,
d
);
}
}
fn
user3
(
d1
:
&
Sec
<
u32
>
,
d2
:
&
Sec
<
u32
>
)
{
println!
(
"user3 {:?}"
,
sec_add_u32
(
d1
,
d2
));
}
fn
user4
(
d
:
&
Sec
<
u32
>
,
e
:
&
Enc
<
u32
>
,
a
:
&
Auth
)
{
println!
(
"user3 {:?}"
,
sec_add_u32
(
d
,
&
e
.get
(
a
)));
}
/*
/*
#![feature(const_fn)]
#![feature(const_fn)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment