Skip to content

Commit 7c63b1d

Browse files
authored
Merge pull request #1170 from JuliaLang/mbedtls
Replace MbedTLS with SHA.jl and bump version
2 parents 040ee20 + ebdbb40 commit 7c63b1d

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "IJulia"
22
uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
3-
version = "1.29.0"
3+
version = "1.29.1"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -10,11 +10,11 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1010
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1111
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1212
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
13-
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
1413
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1514
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1615
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1716
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
17+
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
1818
SoftGlobalScope = "b85f4697-e234-5449-a836-ec8e2f98b302"
1919
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
2020
ZMQ = "c2297ded-f4af-51ae-bb23-16f91089e4e1"
@@ -27,11 +27,11 @@ InteractiveUtils = "1"
2727
JSON = "0.18,0.19,0.20,0.21,1"
2828
Logging = "1"
2929
Markdown = "1"
30-
MbedTLS = "0.5,0.6,0.7,1"
3130
Pkg = "1"
3231
Printf = "1"
3332
REPL = "1"
3433
Random = "1"
34+
SHA = "0.7, 1"
3535
SoftGlobalScope = "1"
3636
UUIDs = "1"
3737
ZMQ = "1.3"

docs/src/_changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ CurrentModule = IJulia
77
This documents notable changes in IJulia.jl. The format is based on [Keep a
88
Changelog](https://keepachangelog.com).
99

10-
## Unreleased
10+
## [v1.29.1] - 2025-07-26
1111

1212
### Changed
1313
- Improved the token-finding functionality to return more accurate tooltips when
1414
Shift + Tab is pressed ([#847]).
15+
- IJulia switched from using MbedTLS.jl to the SHA.jl stdlib. This should not
16+
change anything for users except that now only SHA message digests are
17+
supported instead of e.g. MD5, and Jupyter uses SHA256 by default ([#1170]).
1518

1619
## [v1.29.0] - 2025-06-13
1720

src/IJulia.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The `IJulia` module is used in three ways
3333
module IJulia
3434
export notebook, jupyterlab, installkernel
3535

36+
import SHA
3637
using ZMQ, JSON, SoftGlobalScope
3738
import Base.invokelatest
3839
import Dates

src/hmac.jl

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
using MbedTLS
2-
const hmacstate = Ref{MbedTLS.MD{true}}()
1+
const sha_ctx = Ref{SHA.SHA_CTX}()
2+
const hmac_key = Ref{Vector{UInt8}}()
33

4-
function hmac(s1,s2,s3,s4)
5-
if !isdefined(hmacstate, :x)
4+
function hmac(s1, s2, s3, s4)
5+
if !isassigned(sha_ctx)
66
return ""
77
else
8-
MbedTLS.reset!(hmacstate[])
8+
hmac = SHA.HMAC_CTX(copy(sha_ctx[]), hmac_key[])
99
for s in (s1, s2, s3, s4)
10-
write(hmacstate[], s)
10+
SHA.update!(hmac, codeunits(s))
1111
end
12-
# Take the digest (returned as a byte array) and convert it to hex string representation
13-
digest = MbedTLS.finish!(hmacstate[])
14-
hexdigest = Vector{UInt8}(undef, length(digest)*2)
15-
for i = 1:length(digest)
16-
b = digest[i]
17-
d = b >> 4
18-
hexdigest[2i-1] = UInt8('0')+d+39*(d>9)
19-
d = b & 0xf
20-
hexdigest[2i] = UInt8('0')+d+39*(d>9)
21-
end
22-
return String(hexdigest)
12+
13+
digest = SHA.digest!(hmac)
14+
return bytes2hex(digest)
2315
end
2416
end

src/init.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ function init(args)
8585
isempty(signature_scheme) && (signature_scheme = "hmac-sha256")
8686
sigschm = split(signature_scheme, "-")
8787
if sigschm[1] != "hmac" || length(sigschm) != 2
88-
error("unrecognized signature_scheme $signature_scheme")
88+
error("Unrecognized signature_scheme: $(signature_scheme)")
89+
elseif !startswith(sigschm[2], "sha")
90+
error("Signature schemes other than SHA are not supported on IJulia anymore, requested signature_scheme is: $(signature_scheme)")
8991
end
90-
hmacstate[] = MbedTLS.MD(getfield(MbedTLS, Symbol("MD_", uppercase(sigschm[2]))),
91-
profile["key"])
92+
93+
global sha_ctx[] = getproperty(SHA, Symbol(uppercase(sigschm[2]), "_CTX"))()
94+
global hmac_key[] = collect(UInt8, profile["key"])
9295
end
9396

9497
publish[] = Socket(PUB)

0 commit comments

Comments
 (0)