Tcl Library Source Code

Changes On Branch tcc4tcl-md5
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch tcc4tcl-md5 Excluding Merge-Ins

This is equivalent to a diff from afecf2c9ff to e30cebf96f

2017-05-28
15:26
Add several procedures to the math::numtheory package, such factorising a number and estimating the number of primes up to a certain size. Package version now 1.1 check-in: cd42b3ddf8 user: arjenmarkus tags: trunk
2017-03-30
15:33
Merged tcc4tcl changes check-in: dfe89741cf user: Mark tags: mjanssen-changes
15:30
Simplify md5.c loading Leaf check-in: e30cebf96f user: Mark tags: tcc4tcl-md5
15:16
Create new branch named "mjanssen-changes" check-in: 6076074d50 user: Mark tags: mjanssen-changes
15:16
Use proper folder for loading md5.h check-in: 8650b9654d user: Mark tags: tcc4tcl-md5
14:33
Add tcc4tcl support for md5 check-in: e1741398cd user: mjanssen tags: tcc4tcl-md5
2017-02-15
13:23
dicttool: Added "isnull" command to the dict ensemble processman: Added a concept of "self" to allow a process to tweak its own priority check-in: afecf2c9ff user: tne tags: trunk
2017-02-07
12:37
In Soviet Russia, Fossil Commits YOU check-in: 41bd88ff85 user: hypnotoad tags: trunk

Added modules/md5/md5tcc.tcl.










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# md5tcc.tcl - 
#
# Wrapper for RSA's Message Digest in C
#
# Written by Jean-Claude Wippler <[email protected]>
# Adapted for tcc by Mark Janssen
#

package require tcc4tcl;                 # needs tcc4tcl
package provide md5tcc 0.0.1;              # 

namespace eval ::md5 {
  set handle [tcc4tcl::new]
 
  set source_dir [file dirname [info script]] 
  $handle add_include_path $source_dir
  $handle ccode {#include "md5.c"}

  $handle ccommand md5tcc_final {dummy ip objc objv} {
      MD5_CTX *mp;
      unsigned char *data;
      unsigned char buf[16];
      int size;
      Tcl_Obj *obj;
      if (objc != 2) {
        Tcl_WrongNumArgs(ip, 1, objv, "context");
        return TCL_ERROR;
      }
      obj = objv[1];
      if (Tcl_IsShared(obj)) {
        obj = Tcl_DuplicateObj(obj);
      }
      mp = (MD5_CTX *) Tcl_GetByteArrayFromObj(obj,NULL);
      MD5Final(&buf, mp);
      size = sizeof buf;
      Tcl_SetObjResult(ip, Tcl_NewByteArrayObj(buf,size));
      Tcl_DecrRefCount(obj);
      return TCL_OK;

  }
  $handle ccommand md5tcc {dummy ip objc objv} {
      MD5_CTX *mp;
      unsigned char *data;
      int size;
      Tcl_Obj *obj;

      if (objc < 2 || objc > 3) {
        Tcl_WrongNumArgs(ip, 1, objv, "data ?context?");
        return TCL_ERROR;
      }

      if (objc == 3) {
        obj = objv[2];
        if (Tcl_IsShared(obj)) {
          obj = Tcl_DuplicateObj(obj);
        }
      } else {
        obj = Tcl_NewByteArrayObj(NULL, sizeof *mp);
        Tcl_InvalidateStringRep(obj);
        mp = (MD5_CTX *) Tcl_GetByteArrayFromObj(obj,NULL);
        MD5Init(mp);
      }

      Tcl_InvalidateStringRep(obj);
      mp = (MD5_CTX *) Tcl_GetByteArrayFromObj(obj,NULL);
      data = Tcl_GetByteArrayFromObj(objv[1], &size);
      MD5Update(mp, data, size);
      Tcl_SetObjResult(ip, obj);
      return TCL_OK;
    }

  $handle go
}

Changes to modules/md5/md5x.tcl.

16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30







-
+







# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# -------------------------------------------------------------------------

package require Tcl 8.2;                # tcl minimum version

namespace eval ::md5 {
    variable  accel
    array set accel {critcl 0 cryptkit 0 trf 0}
    array set accel {tcc 0 critcl 0 cryptkit 0 trf 0}

    namespace export md5 hmac MD5Init MD5Update MD5Final

    variable uid
    if {![info exists uid]} {
        set uid 0
    }
81
82
83
84
85
86
87





88
89



90
91
92
93
94
95
96
81
82
83
84
85
86
87
88
89
90
91
92


93
94
95
96
97
98
99
100
101
102







+
+
+
+
+
-
-
+
+
+







#
#   If we have a C-based implementation available, then we will use
#   it here in preference to the pure-Tcl implementation.
#
proc ::md5::MD5Update {token data} {
    variable accel
    upvar #0 $token state
    if {$accel(tcc)} {
        if {[info exists state(md5c)]} {
            set state(md5tcc) [md5tcc $data $state(md5tcc)]
        } else {
            set state(md5tcc) [md5tcc $data]

    if {$accel(critcl)} {
        }
        return
    } elseif {$accel(critcl)} {
        if {[info exists state(md5c)]} {
            set state(md5c) [md5c $data $state(md5c)]
        } else {
            set state(md5c) [md5c $data]
        }
        return
    } elseif {[info exists state(ckctx)]} {
126
127
128
129
130
131
132
133





134
135
136
137
138
139
140
132
133
134
135
136
137
138

139
140
141
142
143
144
145
146
147
148
149
150







-
+
+
+
+
+







#
#    Note that the output is 128 bits represented as binary data.
#
proc ::md5::MD5Final {token} {
    upvar #0 $token state

    # Check for either of the C-compiled versions.
    if {[info exists state(md5c)]} {
    if {[info exists state(md5tcc)]} {
      set r [md5::md5tcc_final $state(md5tcc)]
      unset state
      return $r
    } elseif {[info exists state(md5c)]} {
        set r $state(md5c)
        unset state
        return $r
    } elseif {[info exists state(ckctx)]} {
        cryptkit::cryptEncrypt $state(ckctx) ""
        cryptkit::cryptGetAttributeString $state(ckctx) \
            CRYPT_CTXINFO_HASHVALUE r 16
514
515
516
517
518
519
520






521
522
523
524
525
526
527
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543







+
+
+
+
+
+







#	this should not be called, but the test package manipulates the
#	list of enabled accelerators.
#
proc ::md5::LoadAccelerator {name} {
    variable accel
    set r 0
    switch -exact -- $name {
        tcc {
            if {![catch {package require tcc4tcl}]} {
                package require md5tcc
                set r [expr {[info commands ::md5::md5tcc] != {}}]
            }
        }
        critcl {
            if {![catch {package require tcllibc}]
                || ![catch {package require md5c}]} {
                set r [expr {[info commands ::md5::md5c] != {}}]
            }
        }
        cryptkit {
694
695
696
697
698
699
700
701

702
703
704
705
706
707
708
709
710
711
712
713
710
711
712
713
714
715
716

717
718
719
720
721
722
723
724
725
726
727
728
729







-
+












}

# -------------------------------------------------------------------------

# Try and load a compiled extension to help.
namespace eval ::md5 {
    variable e
    foreach  e {critcl cryptkit trf} { if {[LoadAccelerator $e]} { break } }
    foreach  e {tcc critcl cryptkit trf} { if {[LoadAccelerator $e]} { break } }
    unset    e
}

package provide md5 2.0.7

# -------------------------------------------------------------------------
# Local Variables:
#   mode: tcl
#   indent-tabs-mode: nil
# End:


Changes to modules/md5/pkgIndex.tcl.

1
2
3

1
2
3
4



+
if {![package vsatisfies [package provide Tcl] 8.2]} {return}
package ifneeded md5 2.0.7 [list source [file join $dir md5x.tcl]]
package ifneeded md5 1.4.4 [list source [file join $dir md5.tcl]]
package ifneeded md5tcc 0.0.1 [list source [file join $dir md5tcc.tcl]]