Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Cesium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Cesium-grp
Cesium
Commits
f2c3b51c
Commit
f2c3b51c
authored
8 years ago
by
Benoit Lavenier
Browse files
Options
Downloads
Patches
Plain Diff
- remove nacl_factory when using Android or iOS - fix
#333
- private message was badly encrypted - fix
#345
parent
75e1875d
No related branches found
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
www/css/ionic.app.css
+9
-0
9 additions, 0 deletions
www/css/ionic.app.css
www/css/ionic.app.min.css
+1
-1
1 addition, 1 deletion
www/css/ionic.app.min.css
www/index.html
+4
-5
4 additions, 5 deletions
www/index.html
www/js/services/crypto-services.js
+15
-23
15 additions, 23 deletions
www/js/services/crypto-services.js
with
29 additions
and
29 deletions
www/css/ionic.app.css
+
9
−
0
View file @
f2c3b51c
...
@@ -15054,3 +15054,12 @@ a.underline:hover,
...
@@ -15054,3 +15054,12 @@ a.underline:hover,
font-size: 16px;
font-size: 16px;
left: 25px;
left: 25px;
top: -7px; }
top: -7px; }
div[dropzone] {
border: 2px dashed #bbb;
border-radius: 5px;
padding: 15px;
text-align: center;
font: 20pt bold;
color: #bbb;
margin-bottom: 20px; }
This diff is collapsed.
Click to expand it.
www/css/ionic.app.min.css
+
1
−
1
View file @
f2c3b51c
This diff is collapsed.
Click to expand it.
www/index.html
+
4
−
5
View file @
f2c3b51c
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
<script
src=
"js/vendor/socket-io.js"
></script>
<script
src=
"js/vendor/socket-io.js"
></script>
<script
src=
"js/vendor/underscore.js"
></script>
<script
src=
"js/vendor/underscore.js"
></script>
<script
src=
"js/vendor/qrcode.min.js"
></script>
<script
src=
"js/vendor/qrcode.min.js"
></script>
<!--script src="js/vendor/strophe.min.js"></script-->
<!-- ionic/angularjs js -->
<!-- ionic/angularjs js -->
<script
src=
"lib/ionic/js/ionic.bundle.js"
></script>
<script
src=
"lib/ionic/js/ionic.bundle.js"
></script>
...
@@ -45,13 +44,13 @@
...
@@ -45,13 +44,13 @@
<script
src=
"lib/ionic/js/angular/angular-image-crop.js"
></script>
<script
src=
"lib/ionic/js/angular/angular-image-crop.js"
></script>
<script
src=
"lib/ionic/js/angular/angular-file-saver.bundle.js"
></script>
<script
src=
"lib/ionic/js/angular/angular-file-saver.bundle.js"
></script>
<script
src=
"js/vendor/base58.js"
async
></script>
<script
src=
"js/vendor/base58.js"
async
></script>
<!--removeIf(
device-
android)-->
<!--removeIf(android)-->
<!--removeIf(
device-
ios)-->
<!--removeIf(ios)-->
<script
src=
"js/vendor/nacl_factory.js"
async
></script>
<script
src=
"js/vendor/nacl_factory.js"
async
></script>
<script
src=
"js/vendor/scrypt-em.js"
async
></script>
<script
src=
"js/vendor/scrypt-em.js"
async
></script>
<script
src=
"js/vendor/base64.js"
async
></script>
<script
src=
"js/vendor/base64.js"
async
></script>
<!--endRemoveIf(
device-
ios)-->
<!--endRemoveIf(ios)-->
<!--endRemoveIf(
device-
android)-->
<!--endRemoveIf(android)-->
<!--removeIf(no-device)-->
<!--removeIf(no-device)-->
<script
src=
"js/vendor/sha256.min.js"
async
></script>
<script
src=
"js/vendor/sha256.min.js"
async
></script>
<script
src=
"js/vendor/ng-cordova.min.js"
></script>
<script
src=
"js/vendor/ng-cordova.min.js"
></script>
...
...
This diff is collapsed.
Click to expand it.
www/js/services/crypto-services.js
+
15
−
23
View file @
f2c3b51c
...
@@ -137,8 +137,8 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -137,8 +137,8 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
this
.
util
.
decode_base64
=
function
(
a
)
{
this
.
util
.
decode_base64
=
function
(
a
)
{
return
that
.
base64
.
decode
(
a
);
return
that
.
base64
.
decode
(
a
);
};
};
this
.
util
.
encode_base64
=
function
()
{
this
.
util
.
encode_base64
=
function
(
b
)
{
return
that
.
base64
.
encode
(
arguments
);
return
that
.
base64
.
encode
(
b
);
};
};
this
.
util
.
hash_sha256
=
function
(
message
)
{
this
.
util
.
hash_sha256
=
function
(
message
)
{
...
@@ -177,7 +177,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -177,7 +177,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
/**
/**
* Encrypt a message, from a key pair
* Encrypt a message, from a key pair
*/
*/
this
.
box
=
function
(
message
,
nonce
,
recipientPk
,
senderSk
)
{
this
.
box
=
function
(
message
,
nonce
,
recipientPk
,
senderSk
)
{
return
$q
(
function
(
resolve
,
reject
)
{
return
$q
(
function
(
resolve
,
reject
)
{
if
(
!
message
)
{
if
(
!
message
)
{
resolve
(
message
);
resolve
(
message
);
...
@@ -192,6 +192,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -192,6 +192,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
try
{
try
{
var
ciphertextBin
=
that
.
nacl
.
crypto_box
(
messageBin
,
nonce
,
recipientPk
,
senderSk
);
var
ciphertextBin
=
that
.
nacl
.
crypto_box
(
messageBin
,
nonce
,
recipientPk
,
senderSk
);
var
ciphertext
=
that
.
util
.
encode_base64
(
ciphertextBin
);
var
ciphertext
=
that
.
util
.
encode_base64
(
ciphertextBin
);
//console.debug('Encrypted message: ' + ciphertext);
//console.debug('Encrypted message: ' + ciphertext);
resolve
(
ciphertext
);
resolve
(
ciphertext
);
}
}
...
@@ -350,7 +351,6 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -350,7 +351,6 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
// libraries handlers
// libraries handlers
this
.
nacl
=
null
;
// the cordova plugin
this
.
nacl
=
null
;
// the cordova plugin
this
.
nacl_js
=
null
;
// the full JS lib (need for random values)
this
.
base58
=
null
;
this
.
base58
=
null
;
this
.
sha256
=
null
;
this
.
sha256
=
null
;
var
that
=
this
;
var
that
=
this
;
...
@@ -373,18 +373,19 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -373,18 +373,19 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
for
(
i
=
0
;
i
<
a
.
length
;
i
++
)
b
[
i
]
=
a
[
i
];
for
(
i
=
0
;
i
<
a
.
length
;
i
++
)
b
[
i
]
=
a
[
i
];
return
b
;
return
b
;
};
};
this
.
util
.
decode_base64
=
function
(
a
)
{
return
that
.
nacl
.
from_base64
(
a
);
};
this
.
util
.
encode_base64
=
function
(
b
)
{
return
that
.
nacl
.
to_base64
(
b
);
};
this
.
util
.
hash_sha256
=
function
(
message
)
{
this
.
util
.
hash_sha256
=
function
(
message
)
{
return
$q
.
when
(
that
.
sha256
(
message
).
toUpperCase
());
return
$q
.
when
(
that
.
sha256
(
message
).
toUpperCase
());
};
};
this
.
util
.
random_nonce
=
function
()
{
this
.
util
.
random_nonce
=
function
()
{
if
(
that
.
crypto
&&
that
.
crypto
.
getRandomValues
)
{
var
nonce
=
new
Uint8Array
(
that
.
constants
.
crypto_secretbox_NONCEBYTES
);
var
nonce
=
new
Uint8Array
(
that
.
constants
.
crypto_secretbox_NONCEBYTES
);
that
.
crypto
.
getRandomValues
(
nonce
);
that
.
crypto
.
getRandomValues
(
nonce
);
return
$q
.
when
(
nonce
);
return
$q
.
when
(
nonce
);
}
else
{
return
$q
.
when
(
that
.
nacl_js
.
crypto_box_random_nonce
());
}
};
};
/**
/**
...
@@ -518,7 +519,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -518,7 +519,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
that
.
nacl
.
crypto_box_easy
(
messageBin
,
nonce
,
recipientPk
,
senderSk
,
function
(
err
,
ciphertextBin
)
{
that
.
nacl
.
crypto_box_easy
(
messageBin
,
nonce
,
recipientPk
,
senderSk
,
function
(
err
,
ciphertextBin
)
{
if
(
err
)
{
deferred
.
reject
(
err
);
return
;}
if
(
err
)
{
deferred
.
reject
(
err
);
return
;}
var
ciphertext
=
that
.
nacl
.
to
_base64
(
ciphertextBin
);
var
ciphertext
=
that
.
util
.
encode
_base64
(
ciphertextBin
);
//console.debug('Encrypted message: ' + ciphertext);
//console.debug('Encrypted message: ' + ciphertext);
deferred
.
resolve
(
ciphertext
);
deferred
.
resolve
(
ciphertext
);
});
});
...
@@ -558,10 +559,9 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -558,10 +559,9 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
else
{
else
{
that
.
nacl
=
window
.
plugins
.
MiniSodium
;
that
.
nacl
=
window
.
plugins
.
MiniSodium
;
var
loadedLib
=
0
;
var
loadedLib
=
0
;
var
expectedLoadedLib
=
2
;
var
checkAllLibLoaded
=
function
()
{
var
checkAllLibLoaded
=
function
()
{
loadedLib
++
;
loadedLib
++
;
if
(
loadedLib
==
expectedLoadedLib
)
{
if
(
loadedLib
==
2
)
{
that
.
loaded
=
true
;
that
.
loaded
=
true
;
deferred
.
resolve
();
deferred
.
resolve
();
}
}
...
@@ -574,14 +574,6 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
...
@@ -574,14 +574,6 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services'
that
.
sha256
=
lib
;
that
.
sha256
=
lib
;
checkAllLibLoaded
();
checkAllLibLoaded
();
});
});
if
(
!
that
.
crypto
||
!
that
.
crypto
.
getRandomValues
)
{
console
.
debug
(
'
[crypto] Web Crypto API (window.crypto) NOT exists with getRandomValues. Will load nacl_factory
'
);
expectedLoadedLib
++
;
that
.
async_load_nacl_js
(
function
(
lib
)
{
that
.
nacl_js
=
lib
;
checkAllLibLoaded
();
});
}
}
}
return
deferred
.
promise
;
return
deferred
.
promise
;
...
...
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