doc.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2017 Docker, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Package digest provides a generalized type to opaquely represent message
  15. // digests and their operations within the registry. The Digest type is
  16. // designed to serve as a flexible identifier in a content-addressable system.
  17. // More importantly, it provides tools and wrappers to work with
  18. // hash.Hash-based digests with little effort.
  19. //
  20. // Basics
  21. //
  22. // The format of a digest is simply a string with two parts, dubbed the
  23. // "algorithm" and the "digest", separated by a colon:
  24. //
  25. // <algorithm>:<digest>
  26. //
  27. // An example of a sha256 digest representation follows:
  28. //
  29. // sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc
  30. //
  31. // In this case, the string "sha256" is the algorithm and the hex bytes are
  32. // the "digest".
  33. //
  34. // Because the Digest type is simply a string, once a valid Digest is
  35. // obtained, comparisons are cheap, quick and simple to express with the
  36. // standard equality operator.
  37. //
  38. // Verification
  39. //
  40. // The main benefit of using the Digest type is simple verification against a
  41. // given digest. The Verifier interface, modeled after the stdlib hash.Hash
  42. // interface, provides a common write sink for digest verification. After
  43. // writing is complete, calling the Verifier.Verified method will indicate
  44. // whether or not the stream of bytes matches the target digest.
  45. //
  46. // Missing Features
  47. //
  48. // In addition to the above, we intend to add the following features to this
  49. // package:
  50. //
  51. // 1. A Digester type that supports write sink digest calculation.
  52. //
  53. // 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry.
  54. //
  55. package digest