<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def WriteSignedBinary(binary_urn, binary_content, private_key, public_key, chunk_size = 1024, token = None):
 """Signs a binary and saves it to the datastore. If a signed binary with the given URN already exists, its contents will get overwritten. Args: binary_urn: URN that should serve as a unique identifier for the binary. binary_content: Contents of the binary, as raw bytes. private_key: Key that should be used for signing the binary contents. public_key: Key that should be used to verify the signature generated using the private key. chunk_size: Size, in bytes, of the individual blobs that the binary contents will be split to before saving to the datastore. token: ACL token to use with the legacy (non-relational) datastore. """

  if _ShouldUseLegacyDatastore():
    collects.GRRSignedBlob.NewFromContent(
        binary_content,
        binary_urn,
        chunk_size=chunk_size,
        token=token,
        private_key=private_key,
        public_key=public_key)

  if data_store.RelationalDBEnabled():
    blob_references = rdf_objects.BlobReferences()
    for chunk_offset in range(0, len(binary_content), chunk_size):
      chunk = binary_content[chunk_offset:chunk_offset + chunk_size]
      blob_rdf = rdf_crypto.SignedBlob()
      blob_rdf.Sign(chunk, private_key, verify_key=public_key)
      blob_id = data_store.BLOBS.WriteBlobWithUnknownHash(
          blob_rdf.SerializeToString())
      blob_references.items.Append(
          rdf_objects.BlobReference(
              offset=chunk_offset, size=len(chunk), blob_id=blob_id))
    data_store.REL_DB.WriteSignedBinaryReferences(
        _SignedBinaryIDFromURN(binary_urn), blob_references)