{"id":2473,"date":"2014-07-11T11:55:30","date_gmt":"2014-07-11T15:55:30","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=2473"},"modified":"2014-11-13T12:20:24","modified_gmt":"2014-11-13T17:20:24","slug":"open-symmetric-key","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/","title":{"rendered":"OPEN SYMMETRIC KEY &#8211; Avoid the NULL Ciphertext Trap"},"content":{"rendered":"<div>\n<h3>Introduction<\/h3>\n<p>\nWhen implementing encryption in SQL Server you need to keep track of many moving parts. Some mistakes can make your entire encrypted data unrecoverable.<\/p>\n<p>Today I would like to cover one of those mistakes. It makes your encryption so secure, not even you can decrypt the data.\n<\/p>\n<h3>The Devilishly Silent ENCRYPTBYKEY function<\/h3>\n<p>\nThe <span class=\"tt\">ENCRYPTBYKEY<\/span> function can be used to encrypt data with a <a href=\"http:\/\/sqlity.net\/en\/2278\/symmetric-key\/\">symmetric key<\/a>. To use it you first have to <a href=\"http:\/\/sqlity.net\/en\/2441\/create-symmetric-key\/\">create a symmetric key<\/a> in the current database. Then you can just call the function like this:\n<\/p>\n<div>\n[sql]\nSELECT ENCRYPTBYKEY(KEY_GUID('Key_C'),'Hello World!') AS CipherText;<br \/>\n[\/sql]\n<\/div>\n<p>\nIn this example, \"Key_C\" is the name of the key I previously created and now want to use to encrypt the \"Hello World!\" string. However, the output is somehow not what we would expect:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/the_NULL_ciphertext_trap.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/the_NULL_ciphertext_trap.jpg\" alt=\"Beware of the NULL ciphertext trap.\" title=\"Beware of the NULL ciphertext trap.\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2477\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/the_NULL_ciphertext_trap.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/the_NULL_ciphertext_trap-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/the_NULL_ciphertext_trap-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nThere is no error message, so one would assume that we did everything correctly. But the output of the function is just plain <span class=\"tt\">NULL<\/span>. Maybe this is the result of a new security feature, introduced with SQL Server 2014, that makes sure that nobody can ever break the encryption?\n<\/p>\n<p>\nThis behavior is actually not new. In fact, <span class=\"tt\">ENCRYPTBYKEY<\/span> has behaved this way since it was introduced in SQL Server 2005. The return value being <span class=\"tt\">NULL<\/span> is due to the fact that the key has not been opened. Any time you want to use a symmetric key in SQL Server for any cryptographic action, you have to open it first. If you forget that step, SQL Server will raise an error in some cases. But in other cases, like here when using the <span class=\"tt\">ENCRYPTBYKEY<\/span> function, the failure will be silent. It is up to you to make sure that the appropriate key is not only available, but has also been opened before encrypting data. Otherwise you might end up with a table full of <span class=\"tt\">NULL<\/span>s were you had hoped to find securely encrypted data.\n<\/p>\n<h3>The OPEN SYMMETRIC KEY Statement<\/h3>\n<p>\nTo open a symmetric key, you can use the aptly named <span class=\"tt\">OPEN SYMMETRIC KEY<\/span> statement like this:\n<\/p>\n<div>\n[sql]\nOPEN SYMMETRIC KEY Key_C DECRYPTION BY CERTIFICATE ACertificate;<br \/>\n[\/sql]\n<\/div>\n<p>\nA symmetric key can be protected by either a password, a certificate, an asymmetric key or another symmetric key. (Check out <a href=\"http:\/\/sqlity.net\/en\/2357\/encryption-hierarchy\/\">The SQL Server Encryption Hierarchy<\/a> for details on this.) When you attempt to open a symmetric key, you have to specify the protection mechanism that was used at the time the key was created. The above example shows how to specify a certificate for this purpose.\n<\/p>\n<p>\nWith the key opened, <span class=\"tt\">ENCRYPTBYKEY<\/span> now returns usable data:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg\" alt=\"OPEN SYMMETRIC KEY in Action.\" title=\"OPEN SYMMETRIC KEY in Action.\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2474\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<\/p>\n<h3>Using OPEN SYMMETRIC KEY with Password Protected Protection Mechanisms<\/h3>\n<p>\nCertificates and asymmetric keys are also protected. The certificate in the above example was protected by the <a href=\"http:\/\/sqlity.net\/en\/2373\/create-database-master-key\/\">database master key<\/a> which in turn is protected by the <a href=\"http:\/\/sqlity.net\/en\/2368\/service-master-key\/\">service master key<\/a>. In that situation, we do not need to do anything special to use the certificate. However, if the certificate or asymmetric key is protected with a password instead, we need to specify that password when using the private key. That includes opening a symmetric key that is protected by e.g. a password protected asymmetric key. You can specify the password in the <span class=\"tt\">WITH PASSWORD<\/span> clause of the <span class=\"tt\">OPEN SYMMETRIC KEY<\/span> statement:\n<\/p>\n<div>\n[sql]\nOPEN SYMMETRIC KEY Key_A<br \/>\n  DECRYPTION BY ASYMMETRIC KEY AnAsymmetricKey WITH PASSWORD = '%%%%%%%%%%';<br \/>\n[\/sql]\n<\/div>\n<p>\nThe result is shown below:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_with_password_protected_asymmetric_key.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_with_password_protected_asymmetric_key.jpg\" alt=\"OPEN SYMMETRIC KEY used with password protected asymmetric key.\" title=\"OPEN SYMMETRIC KEY used with password protected asymmetric key.\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2476\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_with_password_protected_asymmetric_key.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_with_password_protected_asymmetric_key-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_with_password_protected_asymmetric_key-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<\/p>\n<h3>OPEN SYMMETRIC KEY for Keys Directly Protected with a Password<\/h3>\n<p>\nWhile it is not necessarily a good practice, you also can protect a symmetric key with a simple password. To open such a key you can simply specify that password in the <span class=\"tt\">DECRYPTION BY PASSWORD<\/span> clause:\n<\/p>\n<div>\n[sql]\nOPEN SYMMETRIC KEY Key_P DECRYPTION BY PASSWORD = '**********';<br \/>\n[\/sql]\n<\/div>\n<p>\nThe reason this is not a good idea is that you cannot chose the algorithm used to encrypt your key when using a password. The algorithm is always triple DES. That algorithm is weaker than the new AES algorithms. Therefore, if you create a key to use it with AES but protect it with a password, you are unnecessarily weakening your encryption from the get-go.\n<\/p>\n<h3>OPEN a SYMMETRIC KEY with Another Symmetric Key<\/h3>\n<p>\nThe last way to protect a symmetric key is to use another symmetric key. The <span class=\"tt\">OPEN SYMMETRIC KEY<\/span> statement in that use case is simple again:\n<\/p>\n<div>\n[sql]\nOPEN SYMMETRIC KEY Key_S DECRYPTION BY SYMMETRIC KEY Key_P;<br \/>\n[\/sql]\n<\/div>\n<p>\nHowever, remember that a symmetric key needs to be open before it can be used. That is true for the protecting key too. So make sure it is open before executing this statement.\n<\/p>\n<p>\nIf you forget to open that key, SQL Server is however nice enough, to actually respond with a meaningful error message:\n<\/p>\n<div>\n[sourcecode]\nMsg 15315, Level 16, State 1, Line 58<br \/>\nThe key 'Key_P' is not open. Please open the key before using it.<br \/>\n[\/sourcecode]\n<\/div>\n<p>\nIf you open the key first, everything works as desired:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_successful_with_other_symmetric_key.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_successful_with_other_symmetric_key.jpg\" alt=\"OPEN SYMMETRIC KEY used successfully with other symmetric key.\" title=\"OPEN SYMMETRIC KEY used successfully with other symmetric key.\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2475\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_successful_with_other_symmetric_key.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_successful_with_other_symmetric_key-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_successful_with_other_symmetric_key-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nBy the way, the <span class=\"tt\">OPEN SYMMETRIC KEY<\/span> statement will not throw an error if the key is open already. In that case, the statement just becomes a No-Op. That means it is safe (and a good practice) to open a symmetric key anytime you want to use it.\n<\/p>\n<h3>Summary <\/h3>\n<p>\nA symmetric key has to be opened before it can be used. SQL Server does however not always complain about a key that has not been opened yet. This can lead to nasty surprises, including data loss, if you are not careful. So, make sure to always open you keys.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t get caught in this nasty trap that will cause all your encrypted data to be wiped out. Discover how to use the OPEN SYMMETRIC KEY statement correctly to protect yourself (and your data) from this ugly surprise.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":2474,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[32,5,34,99,23],"tags":[143,49,273,38,15,140,141],"class_list":["post-2473","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cryptography","category-general","category-security","category-security-pitfalls","category-t-sql-statements","tag-asymmetric-key","tag-certificates","tag-cryptography","tag-security-2","tag-sql-server","tag-symmetric-key","tag-symmetric-key-encryption"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OPEN SYMMETRIC KEY - Avoid the NULL Ciphertext Trap - sqlity.net<\/title>\n<meta name=\"description\" content=\"Don&#039;t get caught in this nasty trap that will wipe out all your encrypted data. Learn how to use the OPEN SYMMETRIC KEY statement to protect yourself.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OPEN SYMMETRIC KEY - Avoid the NULL Ciphertext Trap - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"Don&#039;t get caught in this nasty trap that will wipe out all your encrypted data. Learn how to use the OPEN SYMMETRIC KEY statement to protect yourself.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-11T15:55:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T17:20:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"768\" \/>\n\t<meta property=\"og:image:height\" content=\"468\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"OPEN SYMMETRIC KEY &#8211; Avoid the NULL Ciphertext Trap\",\"datePublished\":\"2014-07-11T15:55:30+00:00\",\"dateModified\":\"2014-11-13T17:20:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/\"},\"wordCount\":949,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/OPEN_SYMMETRIC_KEY_in_action.jpg\",\"keywords\":[\"asymmetric key\",\"Certificates\",\"Cryptography\",\"security\",\"SQL Server\",\"symmetric key\",\"symmetric key encryption\"],\"articleSection\":[\"Cryptography\",\"General\",\"Security\",\"Security Pitfalls\",\"T-SQL Statements\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/\",\"name\":\"OPEN SYMMETRIC KEY - Avoid the NULL Ciphertext Trap - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/OPEN_SYMMETRIC_KEY_in_action.jpg\",\"datePublished\":\"2014-07-11T15:55:30+00:00\",\"dateModified\":\"2014-11-13T17:20:24+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"Don't get caught in this nasty trap that will wipe out all your encrypted data. Learn how to use the OPEN SYMMETRIC KEY statement to protect yourself.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/OPEN_SYMMETRIC_KEY_in_action.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/OPEN_SYMMETRIC_KEY_in_action.jpg\",\"width\":768,\"height\":468,\"caption\":\"OPEN SYMMETRIC KEY in Action.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2473\\\/open-symmetric-key\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OPEN SYMMETRIC KEY &#8211; Avoid the NULL Ciphertext Trap\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OPEN SYMMETRIC KEY - Avoid the NULL Ciphertext Trap - sqlity.net","description":"Don't get caught in this nasty trap that will wipe out all your encrypted data. Learn how to use the OPEN SYMMETRIC KEY statement to protect yourself.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/","og_locale":"en_US","og_type":"article","og_title":"OPEN SYMMETRIC KEY - Avoid the NULL Ciphertext Trap - sqlity.net","og_description":"Don't get caught in this nasty trap that will wipe out all your encrypted data. Learn how to use the OPEN SYMMETRIC KEY statement to protect yourself.","og_url":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2014-07-11T15:55:30+00:00","article_modified_time":"2014-11-13T17:20:24+00:00","og_image":[{"width":768,"height":468,"url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg","type":"image\/jpeg"}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"OPEN SYMMETRIC KEY &#8211; Avoid the NULL Ciphertext Trap","datePublished":"2014-07-11T15:55:30+00:00","dateModified":"2014-11-13T17:20:24+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/"},"wordCount":949,"commentCount":0,"image":{"@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg","keywords":["asymmetric key","Certificates","Cryptography","security","SQL Server","symmetric key","symmetric key encryption"],"articleSection":["Cryptography","General","Security","Security Pitfalls","T-SQL Statements"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/","url":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/","name":"OPEN SYMMETRIC KEY - Avoid the NULL Ciphertext Trap - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg","datePublished":"2014-07-11T15:55:30+00:00","dateModified":"2014-11-13T17:20:24+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"Don't get caught in this nasty trap that will wipe out all your encrypted data. Learn how to use the OPEN SYMMETRIC KEY statement to protect yourself.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#primaryimage","url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg","contentUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg","width":768,"height":468,"caption":"OPEN SYMMETRIC KEY in Action."},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/2473\/open-symmetric-key\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"OPEN SYMMETRIC KEY &#8211; Avoid the NULL Ciphertext Trap"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/OPEN_SYMMETRIC_KEY_in_action.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-DT","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=2473"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2473\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media\/2474"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=2473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=2473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=2473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}