Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vim
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Someone-Else
Vim
Commits
823a1651
Commit
823a1651
authored
14 years ago
by
Bram Moolenaar
Browse files
Options
Downloads
Patches
Plain Diff
Minor updates to blowfish encryption.
parent
40e6a71c
Loading
Loading
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
runtime/doc/todo.txt
+6
-8
6 additions, 8 deletions
runtime/doc/todo.txt
src/blowfish.c
+4
-4
4 additions, 4 deletions
src/blowfish.c
src/proto/sha256.pro
+1
-1
1 addition, 1 deletion
src/proto/sha256.pro
src/sha256.c
+19
-25
19 additions, 25 deletions
src/sha256.c
with
30 additions
and
38 deletions
runtime/doc/todo.txt
+
6
−
8
View file @
823a1651
...
@@ -30,17 +30,15 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
...
@@ -30,17 +30,15 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
*known-bugs*
*known-bugs*
-------------------- Known bugs and current work -----------------------
-------------------- Known bugs and current work -----------------------
check blowfish.c
check sha256.c
Use 'cm' option only when FEAT_CRYPT is defined.
When not full match with magic, check for head and give warning about
unsupported crypt method.
if 'enc' is ucs-2, does utf-8 to ucs-2 encoding always work for seed?
Crypt update:
Crypt update:
- move bf_self_test() and sha256_self_test() elsewhere
- Use 'cm' option only when FEAT_CRYPT is defined.
- When not full match with magic, check for head and give warning about
unsupported crypt method.
- if 'enc' is ucs-2, does utf-8 to ucs-2 encoding always work for seed?
- Update E000 to error number.
- Update E000 to error number.
Include cabal and obj syntax files. (Vincent Berthoux, 2010 May 16)
Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
E315 when trying to change a file in FileChangedRO autocommand event.
E315 when trying to change a file in FileChangedRO autocommand event.
...
...
This diff is collapsed.
Click to expand it.
src/blowfish.c
+
4
−
4
View file @
823a1651
/* vi:set ts=8 sts=4 sw=4:
/* vi:set ts=8 sts=4 sw=4:
*
*
* Blowfish encryption for
v
im; in Blowfish output feedback mode.
* Blowfish encryption for
V
im; in Blowfish output feedback mode.
* GPL(C) Mohsin Ahmed, http://www.cs.albany.edu/~mosh
* GPL(C) Mohsin Ahmed, http://www.cs.albany.edu/~mosh
* Based on http://www.schneier.com/blowfish.html by Bruce Schneier.
* Based on http://www.schneier.com/blowfish.html by Bruce Schneier.
*/
*/
...
@@ -399,10 +399,10 @@ bf_key_init(password)
...
@@ -399,10 +399,10 @@ bf_key_init(password)
{
{
int
i
,
j
,
keypos
=
0
;
int
i
,
j
,
keypos
=
0
;
long_u
val
,
data_l
,
data_r
;
long_u
val
,
data_l
,
data_r
;
char
*
key
;
char
_u
*
key
;
int
keylen
;
int
keylen
;
key
=
sha256_key
(
(
char
*
)
password
);
key
=
sha256_key
(
password
);
keylen
=
STRLEN
(
key
);
keylen
=
STRLEN
(
key
);
for
(
i
=
0
;
i
<
256
;
++
i
)
for
(
i
=
0
;
i
<
256
;
++
i
)
{
{
...
@@ -416,7 +416,7 @@ bf_key_init(password)
...
@@ -416,7 +416,7 @@ bf_key_init(password)
{
{
val
=
0
;
val
=
0
;
for
(
j
=
0
;
j
<
4
;
++
j
)
for
(
j
=
0
;
j
<
4
;
++
j
)
val
=
(
val
<<
8
)
|
(
key
[
keypos
++
%
keylen
]
&
0xff
)
;
val
=
(
val
<<
8
)
|
key
[
keypos
++
%
keylen
];
pax
[
i
]
=
ipa
[
i
]
^
val
;
pax
[
i
]
=
ipa
[
i
]
^
val
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/proto/sha256.pro
+
1
−
1
View file @
823a1651
/*
sha256.c
*/
/*
sha256.c
*/
char
*
sha256_key
__ARGS
((
char
*
buf
));
char
_u
*
sha256_key
__ARGS
((
char
_u
*
buf
));
int
sha256_self_test
__ARGS
((
void
));
int
sha256_self_test
__ARGS
((
void
));
void
sha2_seed
__ARGS
((
char_u
header
[],
int
header_len
));
void
sha2_seed
__ARGS
((
char_u
header
[],
int
header_len
));
/*
vim: set ft=c :
*/
/*
vim: set ft=c :
*/
This diff is collapsed.
Click to expand it.
src/sha256.c
+
19
−
25
View file @
823a1651
...
@@ -28,7 +28,7 @@ static void sha256_starts __ARGS((context_sha256_T *ctx));
...
@@ -28,7 +28,7 @@ static void sha256_starts __ARGS((context_sha256_T *ctx));
static
void
sha256_process
__ARGS
((
context_sha256_T
*
ctx
,
char_u
data
[
64
]));
static
void
sha256_process
__ARGS
((
context_sha256_T
*
ctx
,
char_u
data
[
64
]));
static
void
sha256_update
__ARGS
((
context_sha256_T
*
ctx
,
char_u
*
input
,
uint32_t
length
));
static
void
sha256_update
__ARGS
((
context_sha256_T
*
ctx
,
char_u
*
input
,
uint32_t
length
));
static
void
sha256_finish
__ARGS
((
context_sha256_T
*
ctx
,
char_u
digest
[
32
]));
static
void
sha256_finish
__ARGS
((
context_sha256_T
*
ctx
,
char_u
digest
[
32
]));
static
char
*
sha256_bytes
__ARGS
((
char
*
buf
,
int
buflen
));
static
char
_u
*
sha256_bytes
__ARGS
((
char
_u
*
buf
,
int
buflen
));
static
unsigned
int
get_some_time
__ARGS
((
void
));
static
unsigned
int
get_some_time
__ARGS
((
void
));
...
@@ -277,48 +277,42 @@ sha256_finish(ctx, digest)
...
@@ -277,48 +277,42 @@ sha256_finish(ctx, digest)
PUT_UINT32
(
ctx
->
state
[
7
],
digest
,
28
);
PUT_UINT32
(
ctx
->
state
[
7
],
digest
,
28
);
}
}
static
char
*
/*
* Returns hex digest of "buf[buflen]" in a static array.
*/
static
char_u
*
sha256_bytes
(
buf
,
buflen
)
sha256_bytes
(
buf
,
buflen
)
char
*
buf
;
char
_u
*
buf
;
int
buflen
;
int
buflen
;
{
{
char_u
sha256sum
[
32
];
char_u
sha256sum
[
32
];
static
char
hexit
[
65
];
static
char
_u
hexit
[
65
];
int
j
;
int
j
;
context_sha256_T
ctx
;
context_sha256_T
ctx
;
sha256_self_test
();
sha256_self_test
();
sha256_starts
(
&
ctx
);
sha256_starts
(
&
ctx
);
sha256_update
(
&
ctx
,
(
char_u
*
)
buf
,
buflen
);
sha256_update
(
&
ctx
,
buf
,
buflen
);
sha256_finish
(
&
ctx
,
sha256sum
);
sha256_finish
(
&
ctx
,
sha256sum
);
for
(
j
=
0
;
j
<
32
;
j
++
)
for
(
j
=
0
;
j
<
32
;
j
++
)
sprintf
(
hexit
+
j
*
2
,
"%02x"
,
sha256sum
[
j
]);
sprintf
(
(
char
*
)
hexit
+
j
*
2
,
"%02x"
,
sha256sum
[
j
]);
hexit
[
sizeof
(
hexit
)
-
1
]
=
'\0'
;
hexit
[
sizeof
(
hexit
)
-
1
]
=
'\0'
;
return
hexit
;
return
hexit
;
}
}
/*
/*
* Returns sha256(buf) as 64 hex chars.
* Returns sha256(buf) as 64 hex chars
in static array
.
*/
*/
char
*
char
_u
*
sha256_key
(
buf
)
sha256_key
(
buf
)
char
*
buf
;
char
_u
*
buf
;
{
{
static
char
*
hexit
=
0
;
int
buflen
;
/* No passwd means don't encrypt */
/* No passwd means don't encrypt */
if
(
buf
==
NULL
||
*
buf
==
NUL
)
if
(
buf
==
NULL
||
*
buf
==
NUL
)
return
""
;
return
(
char_u
*
)
""
;
/* if password is "0", reuse previous hash, for user convienience. */
return
sha256_bytes
(
buf
,
STRLEN
(
buf
));
if
(
!
strcmp
(
buf
,
"0"
)
&&
hexit
)
return
hexit
;
buflen
=
strlen
(
buf
);
hexit
=
sha256_bytes
(
buf
,
buflen
);
return
hexit
;
}
}
/*
/*
...
@@ -353,7 +347,7 @@ sha256_self_test()
...
@@ -353,7 +347,7 @@ sha256_self_test()
char_u
buf
[
1000
];
char_u
buf
[
1000
];
char_u
sha256sum
[
32
];
char_u
sha256sum
[
32
];
static
int
failures
=
0
;
static
int
failures
=
0
;
char
*
hexit
;
char
_u
*
hexit
;
static
int
sha256_self_tested
=
0
;
static
int
sha256_self_tested
=
0
;
if
(
sha256_self_tested
>
0
)
if
(
sha256_self_tested
>
0
)
...
@@ -364,9 +358,9 @@ sha256_self_test()
...
@@ -364,9 +358,9 @@ sha256_self_test()
{
{
if
(
i
<
2
)
if
(
i
<
2
)
{
{
hexit
=
sha256_bytes
(
sha_self_test_msg
[
i
],
hexit
=
sha256_bytes
(
(
char_u
*
)
sha_self_test_msg
[
i
],
strlen
(
sha_self_test_msg
[
i
]));
STRLEN
(
sha_self_test_msg
[
i
]));
strcpy
(
output
,
hexit
);
STRCPY
(
output
,
hexit
);
}
}
else
else
{
{
...
...
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