L

libvmod-blobsha256

Varnish module (VMOD) for creating SHA256 digests and hmacs with the VCL data type BLOB.

fb281624 add the hmac function · by Geoff Simmons

vmod_blobsha256

SHA256 digests and hmacs for the VCL blob type

Manual section: 3

SYNOPSIS

import blobsha256 [from "path"] ;

CONTENTS

  • Object blob
  • BLOB blob.hash()
  • BLOB hash(BLOB)
  • BLOB hmac(BLOB, BLOB)
  • Object hmac
  • BLOB hmac.hmac(BLOB)
  • STRING version()

Object hmac

Prototype
new OBJ = blobsha256.hmac(BLOB key)
Description
Creates an object that generates HMACs based on SHA256 and the given key.
Example
new key = blobcode.blob(BASE64, "a2V5"); new hmac = blobsha256.hmac(key.get());

BLOB hmac.hmac(BLOB)

Prototype
BLOB hmac.hmac(BLOB msg)
Description
Returns the HMAC-SHA256 message authentication code for msg based on the key provided in the constructor.
Example
set req.http.hmac = hmac.hmac(blobcode.decode(BASE64, "Zm9v"));

Object blob

Prototype
new OBJ = blobsha256.blob(BLOB blob)
Description
Creates an object that returns the SHA256 digest of the given blob.
Example
new key = blobcode.blob(BASE64, "Zm9v"); new foo = blobsha256.blob(key.get());

BLOB blob.hash()

Prototype
BLOB blob.hash()
Description
Returns the SHA256 digest for the blob given in the constructor.
Example
set req.http.X-Hash = blobcode.encode(BASE64, foo.hash());

BLOB hash(BLOB)

Prototype
BLOB hash(BLOB msg)
Description
Returns the SHA256 digest for msg.

BLOB hmac(BLOB, BLOB)

Prototype
BLOB hmac(BLOB msg, BLOB key)
Description
Returns the SHA256 HMAC for msg based on key.

STRING version()

Prototype
STRING version()
Description
Returns the version string for this VMOD.
Example
std.log("Using VMOD blobsha256 version " + blobsha256.version());