|
|
@@ -30,8 +30,6 @@
|
|
|
package osl
|
|
|
|
|
|
import (
|
|
|
- "bytes"
|
|
|
- "compress/zlib"
|
|
|
"crypto/hmac"
|
|
|
"crypto/md5"
|
|
|
"crypto/sha256"
|
|
|
@@ -41,7 +39,6 @@ import (
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
- "io/ioutil"
|
|
|
"net"
|
|
|
"net/url"
|
|
|
"path"
|
|
|
@@ -750,7 +747,7 @@ func (config *Config) Pave(
|
|
|
return nil, common.ContextError(err)
|
|
|
}
|
|
|
|
|
|
- boxedServerEntries, err := box(fileKey, compress(signedServerEntries))
|
|
|
+ boxedServerEntries, err := box(fileKey, common.Compress(signedServerEntries))
|
|
|
if err != nil {
|
|
|
return nil, common.ContextError(err)
|
|
|
}
|
|
|
@@ -793,7 +790,7 @@ func (config *Config) Pave(
|
|
|
|
|
|
paveFiles = append(paveFiles, &PaveFile{
|
|
|
Name: REGISTRY_FILENAME,
|
|
|
- Contents: compress(signedRegistry),
|
|
|
+ Contents: common.Compress(signedRegistry),
|
|
|
})
|
|
|
|
|
|
return paveFiles, nil
|
|
|
@@ -991,7 +988,7 @@ func GetOSLFilename(baseDirectory string, oslID []byte) string {
|
|
|
func UnpackRegistry(
|
|
|
compressedRegistry []byte, signingPublicKey string) (*Registry, []byte, error) {
|
|
|
|
|
|
- packagedRegistry, err := uncompress(compressedRegistry)
|
|
|
+ packagedRegistry, err := common.Decompress(compressedRegistry)
|
|
|
if err != nil {
|
|
|
return nil, nil, common.ContextError(err)
|
|
|
}
|
|
|
@@ -1173,7 +1170,7 @@ func (registry *Registry) UnpackOSL(
|
|
|
return "", common.ContextError(err)
|
|
|
}
|
|
|
|
|
|
- dataPackage, err := uncompress(decryptedContents)
|
|
|
+ dataPackage, err := common.Decompress(decryptedContents)
|
|
|
if err != nil {
|
|
|
return "", common.ContextError(err)
|
|
|
}
|
|
|
@@ -1283,24 +1280,3 @@ func unbox(key, box []byte) ([]byte, error) {
|
|
|
}
|
|
|
return plaintext, nil
|
|
|
}
|
|
|
-
|
|
|
-func compress(data []byte) []byte {
|
|
|
- var compressedData bytes.Buffer
|
|
|
- writer := zlib.NewWriter(&compressedData)
|
|
|
- writer.Write(data)
|
|
|
- writer.Close()
|
|
|
- return compressedData.Bytes()
|
|
|
-}
|
|
|
-
|
|
|
-func uncompress(data []byte) ([]byte, error) {
|
|
|
- reader, err := zlib.NewReader(bytes.NewReader(data))
|
|
|
- if err != nil {
|
|
|
- return nil, common.ContextError(err)
|
|
|
- }
|
|
|
- uncompressedData, err := ioutil.ReadAll(reader)
|
|
|
- reader.Close()
|
|
|
- if err != nil {
|
|
|
- return nil, common.ContextError(err)
|
|
|
- }
|
|
|
- return uncompressedData, nil
|
|
|
-}
|