I'd like to use Ironclad for md5 hashing and http authentication. Is
there a simple or straight-forward way to convert the string values I
get from http into (simple-array (unsigned-byte 8) (*))?
I keep thinking I've figured this out, but I'm not quite there yet.
(defparameter *data* (make-array 8 :element-type :unsigned-byte
:adjustable nil :fill-pointer nil :displaced-to nil))
works, but
(ironclad:update-digest *digest* *data*)
complains that #(0 0 0 0 0 0 0 0) is not of type (simple-array
(unsigned-byte 8) (*))
and
(type-of *data*) is (simple-vector 8)
and
(type-of (elt *data* 0)) is bit.
Any thoughts? Much appreciated.
"Jonathon McKitrick" <···········@bigfoot.com> writes:
> I'd like to use Ironclad for md5 hashing and http authentication. Is
> there a simple or straight-forward way to convert the string values I
> get from http into (simple-array (unsigned-byte 8) (*))?
Strings generally have more than one possible representation as a
vector of octets. Most implementations that support characters with
character codes >255 also provide some nonstandard way to convert
strings to vectors with a given external format. In Allegro and SBCL
it is named STRING-TO-OCTETS. CLISP provides CONVERT-STRING-TO-BYTES.
The Flexi-Streams package also makes it easy to produce octet vectors
from strings in a portable way. It is located here:
http://weitz.de/flexi-streams/
Zach
Zach Beane wrote:
> "Jonathon McKitrick" <···········@bigfoot.com> writes:
>
> > I'd like to use Ironclad for md5 hashing and http authentication. Is
> > there a simple or straight-forward way to convert the string values I
> > get from http into (simple-array (unsigned-byte 8) (*))?
>
> it is named STRING-TO-OCTETS. CLISP provides CONVERT-STRING-TO-BYTES.
Thanks, that did the trick.
Does anyone know the order in which browsers apply the md5 hash to
username, nonce, and password? I assume I have to do the same,
correct?
"Jonathon McKitrick" <···········@bigfoot.com> writes:
> Does anyone know the order in which browsers apply the md5 hash to
> username, nonce, and password? I assume I have to do the same,
> correct?
This is specified in RFC 2617.
Zach
> This is specified in RFC 2617.
That seems like a very error-prone approach. In other words, if I get
one character wrong, I'll never know which one.
Is this the only way? Is there a tool that can help here?
"Jonathon McKitrick" <···········@bigfoot.com> writes:
> > This is specified in RFC 2617.
>
> That seems like a very error-prone approach. In other words, if I get
> one character wrong, I'll never know which one.
>
> Is this the only way? Is there a tool that can help here?
The standard that defines a protocol is a good place to start when you
decide to implement software compatible with the protocol. What did
you expect instead?
Zach
Zach Beane wrote:
> The standard that defines a protocol is a good place to start when you
> decide to implement software compatible with the protocol. What did
> you expect instead?
Perhaps a tool that would let me build a response piece by piece and
check it along the way, rather than a chicken-and-egg. Right now, I
can't check my code until I implement the algorithm. I can't implement
the algorithm until I check my code.
"Jonathon McKitrick" <···········@bigfoot.com> writes:
> Zach Beane wrote:
>
> > The standard that defines a protocol is a good place to start when you
> > decide to implement software compatible with the protocol. What did
> > you expect instead?
>
> Perhaps a tool that would let me build a response piece by piece and
> check it along the way, rather than a chicken-and-egg. Right now, I
> can't check my code until I implement the algorithm. I can't implement
> the algorithm until I check my code.
This is not a chicken-and-egg problem. First you write the code, then
you test and refine it until it works.
Zach
Jonathon McKitrick <···········@bigfoot.com> wrote:
+---------------
| I'd like to use Ironclad for md5 hashing and http authentication. Is
| there a simple or straight-forward way to convert the string values I
| get from http into (simple-array (unsigned-byte 8) (*))?
|
| I keep thinking I've figured this out, but I'm not quite there yet.
|
| (defparameter *data* (make-array 8 :element-type :unsigned-byte
| :adjustable nil :fill-pointer nil :displaced-to nil))
| works, but
| (ironclad:update-digest *digest* *data*)
| complains that
| #(0 0 0 0 0 0 0 0) is not of type (simple-array (unsigned-byte 8) (*))
| and
| (type-of *data*) is (simple-vector 8)
| and
| (type-of (elt *data* 0)) is bit.
+---------------
The problem is probably that your MAKE-ARRAY is insufficiently-specific
to get what you need. Try executing:
(upgraded-array-element-type 'unsigned-byte)
and see what your local implementation gives you back -- probably T,
but almost certainly *NOT* (UNSIGNED-BYTE 8)!! So try this instead:
> (defparameter *data* (make-array 8 :element-type '(unsigned-byte 8)
:initial-element 0))
*DATA*
> *data*
#(0 0 0 0 0 0 0 0)
> (type-of *data*)
(SIMPLE-ARRAY (UNSIGNED-BYTE 8) (8))
> (type-of (elt *data* 0))
(INTEGER 0 0)
>
It would probably also be good to add an ":INITIAL-ELEMENT 0" to your
MAKE-ARRAY [as I did above], rather than assuming the implementation
will default it for you, since:
If initial-element is not supplied, the consequences of
later reading an uninitialized element of new-array are
undefined unless either initial-contents is supplied or
displaced-to is non-nil.
Conversely, since NIL *is* defined as the default for all of
the :ADJUSTABLE, :FILL-POINTER, & :DISPLACED-TO parameters,
you don't need to specify them here.
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
On 9426 day of my life Jonathon McKitrick wrote:
> I keep thinking I've figured this out, but I'm not quite there yet.
>
> (defparameter *data* (make-array 8 :element-type :unsigned-byte
> :adjustable nil :fill-pointer nil :displaced-to nil))
> Any thoughts? Much appreciated.
There is no such type as :UNSIGNED-BYTE.
-------------------------------------------------------+
|
|
V
(defparameter *data* (make-array 8 :element-type 'unsigned-byte
:adjustable nil
:fill-pointer nil
:displaced-to nil))
--
Ivan Boldyrev
Your bytes are bitten.